Advertisement
GustavoBernardi

Untitled

May 3rd, 2013
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <ctype.h>
  4. int main()
  5. {
  6.     int idade, cont = 0, qtd = 0, somaid = 0;
  7.     char valor;
  8.     do
  9.     {
  10.         printf("Informe idade: ");
  11.         scanf("%d", &idade);
  12.         if (idade > 0){
  13.             printf("Deseja Digitar mais uma Idade:(S ou N) ");
  14.             valor = toupper(getchar());
  15.             fflush(stdin);
  16.             somaid+= idade;
  17.         } else
  18.             printf("Idade Invalida");
  19.         if(valor=='S'||valor=='N'){
  20.             qtd++;
  21.         }
  22.     }
  23.     while (cont > qtd || idade < 0 || valor == 'S');
  24.     if (qtd > 0) {
  25.         printf("Media de idade: %d", somaid / qtd );
  26.     }
  27.     return 1;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement