Advertisement
Guest User

AppEstudante

a guest
Aug 28th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void cadastrar();
  6. void listagem();
  7.  
  8. int i,j=0;
  9. typedef struct {
  10. char nome[100];
  11. char matricula[20];
  12. float nota1;
  13. float nota2;
  14. float nota3;
  15. float nota4;
  16. float media;
  17.                 } cadastro;
  18. cadastro aluno[10];
  19.  
  20. int main(){
  21. char choice;
  22. char wait;
  23. do{
  24. printf ("-------------------------------------------------------------------------\nMenu:\n1. Cadastrar\n2. Listar\n3. Sair\nDigite a opcao desejada: ");
  25.     scanf(" %c", &choice);
  26.     switch (choice){
  27.     case('1'):
  28.     system("CLS");
  29.     printf ("-------------------------------------------------------------------------\n");
  30.     cadastrar();
  31.     printf ("*************************************************************************\n");
  32.     printf("\nAperte qualquer tecla para voltar ao menu.");
  33.     fflush(stdin);
  34.     wait=getchar();
  35.     system("CLS");
  36.     break;
  37.  
  38.     case ('2'):
  39.     system("CLS");
  40.     printf ("-------------------------------------------------------------------------\n");
  41.     listagem();
  42.     printf ("*************************************************************************\n");
  43.     printf("Aperte qualquer tecla para voltar ao menu.");
  44.     fflush(stdin);
  45.     wait=getchar();
  46.     system("CLS");
  47.     break;
  48.  
  49.     case ('3'):
  50.     system("CLS");
  51.     printf ("-------------------------------------------------------------------------\n");
  52.     printf("Fim do Programa.\n");
  53.     break;
  54.  
  55.     default: printf("Digite uma opcao valida!");
  56.     }
  57. }
  58.     while(choice!='3');
  59. return 0;
  60. }
  61.  
  62. void cadastrar() {
  63. printf("\nDigite o nome do aluno: ");
  64. scanf(" %s", &aluno[j].nome);
  65. printf("Digite o numero de matricula: ");
  66. scanf(" %s", &aluno[j].matricula);
  67. printf("Digite as notas: ");
  68. printf("\nNota 1: ");
  69. scanf(" %f", &aluno[j].nota1);
  70. printf("Nota 2: ");
  71. scanf(" %f", &aluno[j].nota2);
  72. printf("Nota 3: ");
  73. scanf(" %f", &aluno[j].nota3);
  74. printf("Nota 4: ");
  75. scanf(" %f", &aluno[j].nota4);
  76. j++;
  77. }
  78.  
  79. void listagem() {
  80.  for(i=0;i<j;i++){
  81. aluno[i].media =(aluno[i].nota1 + aluno[i].nota2 + aluno[i].nota3 + aluno[i].nota4)/4;
  82. printf("\nNome: %s\nMatricula: %s\nNota 1: %.2f\nNota 2: %.2f\nNota 3: %.2f\nNota 4: %.2f\nMedia: %.2f\n",aluno[i].nome, aluno[i].matricula, aluno[i].nota1, aluno[i].nota2, aluno[i].nota3, aluno[i].nota4, aluno[i].media);
  83.  }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement