diogoAlves

IFF/Introdução à Programação/Lista/41

Feb 22nd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. //IFF - Introdução à Programação
  2. //Lista de Exercicios - 41
  3. #include<stdio.h>
  4. #include<locale.h>
  5. #include<string.h>
  6.  
  7. int main(void){
  8.     setlocale(LC_ALL,"Portuguese");
  9.     char nome[20],nomeMaior[20];
  10.     float altura, maior, menor, media = 0;
  11.     int i;
  12.     for(i=0;i<20;i++){
  13.         setbuf(stdin,NULL);
  14.         printf("Entre com o nome: ");
  15.         gets(nome);
  16.         printf("Entre com a altura: ");
  17.         scanf(" %f",&altura);
  18.         if(i==0) menor=altura;
  19.         if(maior<=altura){
  20.             strcpy(nomeMaior,nome);
  21.             maior=altura;
  22.         }else menor=altura;
  23.         media+=altura;
  24.     }
  25.     printf("A menor altura registrada foi %.2f\nA maior altura registrada foi do %s\nA média de todas alturas foi %.2f",menor,nomeMaior,media/20);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment