Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main ()
- {
- int suma = 0;
- int liczba;
- int licznik = -1;
- do
- {
- cout << "Podaj liczbe: ";
- cin >> liczba;
- suma += liczba;
- ++licznik;
- } while(liczba != 0);
- cout.precision(10); // ustalenie ile cyfr ma być wyświetlanych
- if(licznik > 0)
- cout << "Srednia arytmetyczna podanych liczb wynosi " << 1.0 * suma / licznik << endl;
- else
- cout << "Nie wpisales zadnej liczby.\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement