Advertisement
chevengur

Вводный курс: основы C++ | Урок 7: Выход из цикла 2/2

Aug 25th, 2023 (edited)
106
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 1 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int bill;
  6.     int sum = 0;
  7.  
  8.     do {
  9.         cin >> bill;
  10.         if (bill > 0) {
  11.             cout << "Income: " << bill << endl;
  12.             sum += bill;
  13.         }
  14.  
  15.     // признаком конца программы будет счёт ноль
  16.     } while (bill != 0);
  17.  
  18.     cout << "Total income: " << sum << endl;
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement