Advertisement
AshfaqFardin

Sum of Continuous input

Jul 30th, 2021
1,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int sum = 0;
  8.     int value = 0;
  9.     while(true){
  10.         cout << "Enter a value: ";
  11.         cin >> value;
  12.        
  13.         if(value == 0){
  14.             break;
  15.         }
  16.         sum += value;
  17.         cout << "Running total is: " << sum << endl;
  18.     }
  19.    
  20.    
  21.     return 0;
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement