Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <ctype.h>
- int main()
- {
- int idade, cont = 0, qtd = 0, somaid = 0;
- char valor;
- do
- {
- printf("Informe idade: ");
- scanf("%d", &idade);
- if (idade > 0){
- printf("Deseja Digitar mais uma Idade:(S ou N) ");
- valor = toupper(getchar());
- fflush(stdin);
- somaid+= idade;
- } else
- printf("Idade Invalida");
- if(valor=='S'||valor=='N'){
- qtd++;
- }
- }
- while (cont > qtd || idade < 0 || valor == 'S');
- if (qtd > 0) {
- printf("Media de idade: %d", somaid / qtd );
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement