Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // iteracyjne.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <conio.h>
- int main()
- {
- float liczba, suma = 0, srednia;
- int licznik = 0;
- printf("Podaj kolejne liczby, 0 konczy wprowadzanie \n");
- do
- {
- licznik++;
- scanf("%f", &liczba);
- suma += liczba;
- }
- while (liczba != 0);
- if (liczba == 0 && licznik == 1)
- {
- printf("Koniec");
- }
- else if (liczba == 0 && licznik != 1)
- {
- printf("Suma = %f\n", suma);
- srednia = suma / (licznik - 1);
- printf("Srednia = %f\n", srednia);
- }
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment