Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- using namespace std;
- float LiczSrednia(float xSuma, float xIloscLiczb)
- {
- return xSuma/xIloscLiczb;
- }
- int main()
- {
- int IloscLiczb;
- float Liczba, Suma = 0;
- cout<<"Podaj ilosc liczb, z ktorych chcesz wyliczyc srednia!"<<endl;
- cin>>IloscLiczb;
- for (int i=1; i<=IloscLiczb; i++)
- {
- cout<<"Podaj liczbe nr "<<i<<"!"<<endl;
- cin>>Liczba;
- Suma = Suma + Liczba;
- }
- cout<<"Srednia z tych liczb wynosi: "<<LiczSrednia(Suma, IloscLiczb);
- getchar();
- cin.ignore();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement