#include <iostream>
usingnamespace std;
//This is a basic hello world program and basic calculator combined
/* This is
* A multi line
* comment
*/
void endmessage()
{
cout << "Goodbye World" << endl;
}
//the int main will be the first part of code that the computer reads
int main()
{
//this section declared variables so they can later be called upon
//They are given initial values to help with debugging
int x = 1;
int y = 1;
int total = x + y;
//This will prompt the user to type in 2 numbers, then the program will return the sum of the numbers
cout << "Hello World \n\n";
cout << "Type in a number...\n";
cin >> x;
cout << "\nType in another number...\n";
cin >> y;
cout << "\nYour total is " << total << "\n\n";
endmessage();
return 0;
}
int x = 1;
int y = 1;
int total = x + y; // Sets total to 2 (1 + 1)
total gets set to the sum of x and y at the time that that line is executed.
Which is 2.
The line int total = x + y; doesn't "bind" the formula x + y to the variable total.
(Remember, total is just an int...so it can only hold integer values, not algebraic formulas.)