Sanlover

Untitled

Oct 26th, 2021
1,069
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.   int summary = 0, amount = 0, temp, a, b;
  6.   bool isEnded = false;
  7.  
  8.   cout << "Enter a: ";
  9.   cin >> a;
  10.   cout << "Enter b: ";
  11.   cin >> b;
  12.  
  13.   while (!isEnded) {
  14.     cin >> temp;
  15.     if (temp == 0) {
  16.       isEnded = true;
  17.     } else {
  18.       if (temp >= a && temp <= b) {
  19.         summary += temp;
  20.         amount++;
  21.       }
  22.     }
  23.   }
  24.   cout << "Amount = " << amount << endl << "Summary = " << summary;
  25.   return 0;
  26. }
  27.  
RAW Paste Data