// Comments begin with "//" and end at the line's end. // Comments are not part of the program, but help human understanding. // Oldham, Jeffrey D. // 1999 Sep 07 // CS 1320 // // Program to Add Two Integers // input <- Prompted by the program, the user types two integers. // output-> The integers' sum is printed. // All C++ programs begin with the following two lines. #include int main() { // The important part of the program goes here. // First, we will ask the user for an integer. int first_integer; // This line says that the name // "first_integer" is a variable that // represents an integer. cout << "Please enter an integer: "; // Print this on the screen. cin >> first_integer; // Store the integer that the user types in // the variable called "first_integer". // Now, we will ask for a second integer. int second_integer; cout << "Please enter an integer: "; cin >> second_integer; // Now we will print the sum of the integers. int sum = first_integer + second_integer; // This statement does two things: // 1) It declares an integer variable called "sum". // 2) It assigns the value of the sum of // first_integer and second_integer to "sum". cout << "The sum is " << sum << ".\n"; // This prints the sum on the screen. // The "\n" means print a newline. That is, // end the line and move the cursor to the // beginning of the next line. // The important part of the program ends here. // All C++ programs end with the following two lines. return 0; }