fork download
  1. // Marvyn De La Torre CS1A Chapter 2, P. 81, #1
  2.  
  3. /****************************************************************
  4.  * ADD TWO NUMBERS
  5.  * --------------------------------------------------------------
  6.  * This program assigns the values 62 and 99 to two integer
  7.  * variables. It adds them together and displays the total.
  8.  * --------------------------------------------------------------
  9.  * INPUT
  10.  * number1 : First integer
  11.  * number2 : Second integer
  12.  *
  13.  * OUTPUT
  14.  * total : Sum of the two integers
  15.  ****************************************************************/
  16.  
  17. #include <iostream>
  18. using namespace std;
  19.  
  20. int main()
  21. {
  22. int number1; // INPUT - First integer
  23. int number2; // INPUT - Second integer
  24. int total; // OUTPUT - Sum of both integers
  25.  
  26. // Assign the required values
  27. number1 = 62;
  28. number2 = 99;
  29.  
  30. // Add the two numbers
  31. total = number1 + number2;
  32.  
  33. // Display the result
  34. cout << "The sum of " << number1 << " and "
  35. << number2 << " is: " << total << endl;
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
The sum of 62 and 99 is: 161