How do I create a calculation program with C++.
As always first I begin with a empty file named test.cpp.
Declaring integer to store four variables.
int number1, number2, number3, sum;
Then following with cout, in C++ cout prints on the screen, cin is an input, asks user to enter a number or character, as for the endl, stands for end of line.
cout << "Add 10 to the sum" << endl;
I am adding three times cout and cin, because each time should print on the screen and to keep user informed what to do.
At this program i am calculating with addition +, it works the same using others arithmetics, simple change to - substruct, or * multiply, or / to divide.
sum = number1 + number2 + number3;
Watch live in action creating the program, or scroll below to copy the entire code.
Feel free to use the code.
Last update .