fork download
  1. //Zachary Abdollahi CS1A Chapter 2, P. 81, #1
  2. //
  3. /*****************************************************************************
  4.  * CALCULATE SUM OF NUMBERS
  5.  * ___________________________________________________________________________
  6.  *
  7.  * This program accepts two integers and computes the sum of the two integers.
  8.  *
  9.  * Computation is based on the formula:
  10.  * Total = num1 + num2
  11.  * ___________________________________________________________________________
  12.  * INPUT
  13.  * num1 : First integer summand
  14.  * num2 : Second integer value (99)
  15.  *
  16.  * OUTPUT
  17.  * total = : Sum of num1 and num2
  18.  ****************************************************************************/
  19.  
  20. #include <iostream>
  21. #include <iomanip>
  22. using namespace std;
  23. int main() {
  24. // Store the given integers in variables
  25. int num1; //First addend
  26. int num2; //Second addend
  27. int total; //Sum of first and second addends
  28.  
  29. num1 = 62; //Assign value to first addend
  30. num2 = 99; //Assign value to second addend
  31.  
  32. // Calculate the sum and store it in a variable named 'total'
  33. total = num1 + num2;
  34.  
  35. // Output the result
  36. cout << "The sum of " << num1 << " and " << num2 << " is: " << total << endl;
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
The sum of 62 and 99 is: 161