Created
March 5, 2017 10:11
-
-
Save FelipeGrijo/77b092405b8636d930e05cab0ef1c9a7 to your computer and use it in GitHub Desktop.
5. Faça um procedimento que leia um número não determinado de valores positivos e mostre a média aritmética desses número.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://gist.github.com/FelipeGrijo | |
#include <stdio.h> | |
void Media(int qnt){ | |
int x=0; | |
float Numeros,SomaNumeros,ResultMedia=0.0; | |
for(x=1;x<=qnt;x++){ | |
printf("Digite o numero %d:",x); | |
scanf("%f",&Numeros); | |
SomaNumeros+=Numeros; | |
} | |
ResultMedia=SomaNumeros/qnt; | |
printf("A media e %.2f\n",ResultMedia); | |
} | |
int main(){ | |
int Qnt=0; | |
do{ | |
printf("Digite a quantidade de numeros que deseja fazer a media:"); | |
scanf("%d",&Qnt); | |
}while(Qnt<=0); | |
Media(Qnt); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment