Advertisement
MeehoweCK

Untitled

Dec 10th, 2020
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. /*Napisz program, który pobiera od użytkownika kolejne liczby
  6. naturalne dotąd, aż użytkownik poda liczbę zero.
  7. Wówczas program ma wypisać sumę podanych liczb.*/
  8.  
  9. int main()
  10. {
  11.     int liczba;
  12.     int suma = 0;
  13.  
  14.     do
  15.     {
  16.         cin >> liczba;
  17.         suma += liczba;
  18.     } while(liczba != 0);
  19.  
  20.     cout << suma << endl;
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement