Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /*Napisz program, który pobiera od użytkownika liczby całkowite dotąd aż poda on liczbę 0.
- Następnie program ma wypisać na ekran średnią arytmetyczną wpisanych liczb (0 ma być liczone).*/
- int main()
- {
- int liczba;
- unsigned licznik = 0;
- int suma = 0;
- do
- {
- cin >> liczba;
- ++licznik;
- suma += liczba;
- } while(liczba != 0);
- cout << "Srednia podanych liczb wynosi " << 1.0 * suma / licznik << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement