## Get Coefficient

0 likes • Nov 18, 2022 • 2 views
C++

## More C++ Posts

#### Big O(n^2) Ascending Sort

0 likes • Nov 18, 2022 • 5 views
C++
```#include <iostream>using namespace std;
int main() {

int arr[5];        for(int i = 0; i < 5; i++) {        arr[i] = i;    }
for(int i = 0; i < 5; i++) {        cout << "Outputting array info at position " << i + 1 << ": " << arr[i] << endl;    }
for(int i=0;i<5;i++)	{				for(int j=i+1;j<5;j++)		{			if(arr[i]>arr[j])			{				int temp=arr[i];				arr[i]=arr[j];				arr[j]=temp;			}		}	}
cout << endl;
for(int i = 0; i < 5; i++) {        cout << "Outputting sorted array info at position " << i + 1 << ": " << arr[i] << endl;    }
return 0;}```

#### Stock Options Analyzer

0 likes • Nov 18, 2022 • 0 views
C++
```#include <iostream>#include <cmath>#include <string.h>
using namespace std;
int main() {
string tickerName;    int numOfContracts;    float currentOptionValue;
cout << "Enter a stock ticker: ";    getline(cin, tickerName);
cout << "Enter the current number of " << tickerName << " contracts you are holding: ";    cin >> numOfContracts;

cout << "Enter the current price of the option: ";    cin >> currentOptionValue;

cout << "The value of your " << tickerName << " options are: \$" << (currentOptionValue * 100.00) * (numOfContracts);
cout << endl;
return 0;}```

#### Daily: Find missing array value

0 likes • Aug 5, 2023 • 5 views
C++
```/*Good morning! Here's your coding interview problem for today.
This problem was asked by Stripe.
Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.
For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
You can modify the input array in-place.*/#include <iostream>using namespace std;
int calcMissing(int* input, int size){	int sum = 0;	int n = 1; //add one to account for missing value	for(int i = 0; i < size; i++)	{	if(input[i] > 0)	{	sum += input[i];	n++;	}	}
//If no numbers higher than 0, answer is 1	if(sum == 0)	return 1;
return (n*(n+1)/2) - sum; //Formula is expectedSum - actualSum	/* expectedSum = n*(n+1)/2, the formula for sum(1, n) */}
int main(){
cout << calcMissing(new int[4]{3, 4, -1, 1}, 4) << endl;	cout << calcMissing(new int[3]{1, 2, 0}, 3) << endl;
//No positive numbers	cout << calcMissing(new int[1]{0}, 1) << endl;}```

#### Two Letter Combinations

0 likes • Nov 18, 2022 • 0 views
C++
```#include <iostream>#include <fstream>#include <string>#include <cstring>
using namespace std;
//This program makes a new text file that contains all combinations of two letters.// aa, ab, ..., zy, zz
int main(){	string filename = "two_letters.txt";
ofstream outFile;	outFile.open(filename.c_str());
if(!outFile.is_open()){		cout << "Something's wrong. Closing..." << endl;		return 0;	}
for(char first = 'a'; first <= 'z'; first++){		for(char second = 'a'; second <= 'z'; second++){			outFile << first << second << " ";		}		outFile << endl;	}
return 0;}```

#### Hello, World!

0 likes • Nov 18, 2022 • 2 views
C++
```#include <iostream>using namespace std;
int main(){    cout << "Hello, World!" << endl;    return 0;}```

#### Literal Bruh

0 likes • Jul 30, 2023 • 5 views
C++
```//Constant prefix notation solver using bruh//Could make it infix or postfix later#include<string>#include<vector>#include<iostream>
std::vector<long double> bruhBuff;
long double operator ""bruh(long double a){    bruhBuff.push_back(a);    return a;}
long double operator ""bruh(const char op){    if(bruhBuff.size() < 2) throw "Bruh weak";        long double b = bruhBuff.back();    bruhBuff.pop_back();    long double a = bruhBuff.back();    bruhBuff.pop_back();            switch(op){        case (int)('+'):            return a + b;        case (int)('-'):            return a - b;        case (int)('*'):            return a * b;        case (int)('/'):            return a / b;    }    return 69l;} int main(){    1.0bruh;    2.0bruh;    std::cout << '+'bruh << std::endl;        return 0;}```