ramontricolor12

LISTA 06 - Exercício 06

Jul 15th, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. /* CABEÇALHO
  2.    Arquivo: LISTA 06 - Exercicio 6.c
  3.    Objetivo: Exibir nome do aluno que possui maior media.
  4.    Autor(a): Ramon Borges
  5.  */
  6.  
  7. #include <stdio.h>
  8. #define MAX 5
  9.  
  10. struct info
  11. {
  12.     char nome[30];
  13.     float media;
  14. };
  15.  
  16. int main()
  17. {
  18.     struct info alunos[MAX];
  19.     int i, maior = 0;
  20.  
  21.     for(i = 0; i < MAX; i++)
  22.     {
  23.         printf("\nInforme o nome do %d aluno: ", i+1);
  24.         fflush(stdin);
  25.         gets(alunos[i].nome);
  26.         printf("\nInforme sua media: ");
  27.         scanf("%f", &alunos[i].media);
  28.     }
  29.     for(i = 0; i < MAX; i++)
  30.         if(alunos[i].media > alunos[maior].media)
  31.             maior = i;
  32.     printf("\nMAIOR MEDIA: %s", alunos[maior].nome);
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment