Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void cadastrar();
- void listagem();
- int i,j=0;
- typedef struct {
- char nome[100];
- char matricula[20];
- float nota1;
- float nota2;
- float nota3;
- float nota4;
- float media;
- } cadastro;
- cadastro aluno[10];
- int main(){
- char choice;
- char wait;
- do{
- printf ("-------------------------------------------------------------------------\nMenu:\n1. Cadastrar\n2. Listar\n3. Sair\nDigite a opcao desejada: ");
- scanf(" %c", &choice);
- switch (choice){
- case('1'):
- system("CLS");
- printf ("-------------------------------------------------------------------------\n");
- cadastrar();
- printf ("*************************************************************************\n");
- printf("\nAperte qualquer tecla para voltar ao menu.");
- fflush(stdin);
- wait=getchar();
- system("CLS");
- break;
- case ('2'):
- system("CLS");
- printf ("-------------------------------------------------------------------------\n");
- listagem();
- printf ("*************************************************************************\n");
- printf("Aperte qualquer tecla para voltar ao menu.");
- fflush(stdin);
- wait=getchar();
- system("CLS");
- break;
- case ('3'):
- system("CLS");
- printf ("-------------------------------------------------------------------------\n");
- printf("Fim do Programa.\n");
- break;
- default: printf("Digite uma opcao valida!");
- }
- }
- while(choice!='3');
- return 0;
- }
- void cadastrar() {
- printf("\nDigite o nome do aluno: ");
- scanf(" %s", &aluno[j].nome);
- printf("Digite o numero de matricula: ");
- scanf(" %s", &aluno[j].matricula);
- printf("Digite as notas: ");
- printf("\nNota 1: ");
- scanf(" %f", &aluno[j].nota1);
- printf("Nota 2: ");
- scanf(" %f", &aluno[j].nota2);
- printf("Nota 3: ");
- scanf(" %f", &aluno[j].nota3);
- printf("Nota 4: ");
- scanf(" %f", &aluno[j].nota4);
- j++;
- }
- void listagem() {
- for(i=0;i<j;i++){
- aluno[i].media =(aluno[i].nota1 + aluno[i].nota2 + aluno[i].nota3 + aluno[i].nota4)/4;
- 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);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement