fork download
  1. //Matthew Santos CS1A Ch. 3, Pg. 146, #15
  2. /***********************************************
  3.  *
  4.  * PRACTICE ADDITION PROBLEM
  5.  * _____________________________________________
  6.  * Adds any two numbers, waits for the enter
  7.  * key and then displays the answer.
  8.  * _____________________________________________
  9.  * INPUT
  10.  * num1 : number 1
  11.  * num2 : number 2
  12.  * OUTPUT
  13.  * sum : sum of numbers 1 and 2
  14.  ***********************************************/
  15. #include <iostream>
  16. #include <iomanip>
  17. using namespace std;
  18.  
  19. int main() {
  20.  
  21. //Establish numbers
  22. float num1;
  23. float num2;
  24. float sum;
  25.  
  26. //Acquire two numbers
  27. cin >> num1 >> num2;
  28.  
  29. //Calculates and sum and waits for enter key
  30. sum = num1 + num2;
  31. cout << num1 << " + " << num2 << " = ";
  32. cin.get();
  33. cout << sum;
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 5324KB
stdin
50 50
stdout
50 + 50 = 100