fork download
  1. // Torrez, Elaine CS1A Chapter 2 P. 81, #1
  2.  
  3. /******************************************************************************************
  4.  *
  5.  * SUM OF TWO NUMBERS
  6.  *
  7.  * --------------------------------------------------------------------------------
  8.  * This program stores two integers, adds them together, and displays the sum.
  9.  * --------------------------------------------------------------------------------
  10.  *
  11.  * INPUT
  12.  * num1 : first integer
  13.  * num2 : second integer
  14.  *
  15.  * OUTPUT
  16.  * total : sum of num1 and num2
  17.  *
  18.  *******************************************************************************************/
  19.  
  20. #include <iostream>
  21. using namespace std;
  22.  
  23. int main()
  24. {
  25. int num1; // First integer
  26. int num2; // Second integer
  27. int total; // Sum of num1 and num2
  28.  
  29. num1 = 62; // INPUT first number
  30. num2 = 99; // INPUT second number
  31.  
  32. total = num1 + num2; // Compute sum
  33.  
  34. // OUTPUT total
  35. cout << "The sum of " << num1 << " and " << num2
  36. << " is " << total << "." << endl;
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
The sum of 62 and 99 is 161.