Advertisement
gtw7375

apostila while - question 5

Sep 16th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.14 KB | None | 0 0
  1.  main() {
  2.    
  3. int idade, soma=0, media, menor, maior, cont=0;
  4.                
  5.                 printf("Informe sua idade:");
  6.                 scanf("%d", &idade);
  7.                 maior = idade;
  8.                 menor = idade;
  9.                
  10.                 while(idade!=0) {
  11.                                 cont++;
  12.                                 soma +=idade;
  13.                                
  14.                                 if(idade>maior) {
  15.                                     maior=idade;
  16.                                 }
  17.                                 if(idade<menor) {
  18.                                     menor = idade;
  19.                                 }
  20.                                 printf("Informe sua idade:");
  21.                                 scanf("%d", &idade);
  22.                                
  23.                 }
  24.                  
  25.                  media = soma/cont;
  26.        
  27.                
  28.                 printf("Idade media: %d", media);
  29.                  printf("Numero de pessoas: %d", cont);
  30.                   printf("Maior idade: %d", maior);
  31.                    printf("Menor idade: %d", menor);
  32.                
  33.         getch();
  34.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement