-
Math problem(s) in C++
My friend recently challenged me to writing a program that calculates a somewhat complex math problem. I dont want to state that problem here because he would think i was cheating. The thing is, i spent over an hour trying to write a program even to calculate a simple thing like 2+2 i tried looping and all that jazz but i guess i cant get the syntax, if someone would explain to me how to write a program that would say something like: "enter numbers to be added"
and then when you press enter it adds them.
and you receive the answer.
this wont effect my challenge, i still have to come up with a formula for the problem and figure out how to make it do what i want with the answer, i just need some help getting started writing a calculator (basically) but a calculator that does what i want.
-
Code:
#include <iostream.h>
void main() {
int num1, num2;
cout << "Number 1: "; cin >> num1;
cout << "\nNumber 2: "; cin >> num2;
cout << "\nAnswer = "<< num1+num2 << endl;
}
Something like this perhaps?