Advertisement
MeehoweCK

Untitled

Jun 4th, 2021
1,106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7.     int suma = 0;
  8.     int liczba;
  9.     int licznik = -1;
  10.  
  11.     do
  12.     {
  13.         cout << "Podaj liczbe: ";
  14.         cin >> liczba;
  15.         suma += liczba;
  16.         ++licznik;
  17.     } while(liczba != 0);
  18.  
  19.     cout.precision(10);     // ustalenie ile cyfr ma być wyświetlanych
  20.     if(licznik > 0)
  21.         cout << "Srednia arytmetyczna podanych liczb wynosi " << 1.0 * suma / licznik << endl;
  22.     else
  23.         cout << "Nie wpisales zadnej liczby.\n";
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement