Created
November 3, 2017 13:30
-
-
Save hc3/83876f4a6efdec078214b5e0e13a4a85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
DISCIPLINA: ESTRUTURA DE DADOS | |
PROFESSOR: JOSÉ HONORATO FERREIRA NUNES | |
DATA DA AULA : 03/11/2017 | |
DATA DA ENTREGA : 09/11/2017 | |
ENVIAR P/ : honoratonunes@gmail.com | |
Escrever um programa que cadastre o nome, a matrÃcula e duas notas | |
de vários alunos. Em seguida imprima a matrÃcula, o nome e a média de | |
cada um deles. | |
*/ | |
#include <stdio.h> | |
#include <locale.h> | |
/* STRUCT com as informações do Aluno */ | |
typedef struct { | |
char nome[20]; | |
int matricula; | |
float primeiraNota; | |
float segundaNota; | |
} Aluno; | |
/* DECLARAÇÃO DOS MÉTODOS */ | |
void insertAndPrintInfoAlunos( Aluno *vetorAluno, int tamanho); | |
main() { | |
setlocale(LC_ALL,"portuguese_Brazil"); | |
Aluno alunoList[2]; | |
insertAndPrintInfoAlunos(alunoList, 2); | |
} | |
/* | |
função que insere e mostra os dados do aluno | |
*/ | |
void insertAndPrintInfoAlunos( Aluno *vetorAluno, int tamanho) { | |
int num; | |
float avrg; | |
/* | |
um for que acessa cada posição no vetor de Alunos e através do . ( ponto ) da pra acessar a propriedade | |
do struct, exemplo : vetor[num].nome | |
*/ | |
for(num = 0; num < tamanho; num++) { | |
printf("### PREENCHENDO INFORMAÇÕES DO %dº ALUNO ### \n\n",num+1); | |
printf("Digite o nome do aluno: "); | |
scanf("%s",vetorAluno[num].nome); | |
printf("Digite a matricula do aluno: "); | |
scanf("%d",&vetorAluno[num].matricula); | |
printf("Digite a primeira nota do aluno: "); | |
scanf("%f",&vetorAluno[num].primeiraNota); | |
printf("Digite a segunda nota do aluno: "); | |
scanf("%f",&vetorAluno[num].segundaNota); | |
printf("### -- FIM CADASTRO DO ALUNO : %s",vetorAluno[num].nome); | |
printf("\n\n\n"); | |
} | |
/* | |
vetor que mostra as informações | |
*/ | |
for(num = 0; num < tamanho; num++) { | |
printf("### EXIBINDO INFORMAÇÕES DO DO %dº ALUNO ### \n\n",num+1); | |
printf("Matricula : %d \n",vetorAluno[num].matricula); | |
printf("Nome : %s \n",vetorAluno[num].nome); | |
// PROCESSAMENTO PARA EXIBIR A MÉDIA | |
printf("Media : %f \n",(vetorAluno[num].primeiraNota + vetorAluno[num].segundaNota) / 2); | |
printf("### -- ================== --##"); | |
printf("\n\n\n"); | |
} | |
} |
Author
hc3
commented
Nov 3, 2017
#include <stdio.h>
#include <locale.h>
#define qtd 2
struct cadastro{
char nome[10];
int matricula;
float nota1, nota2;
};
int main(){
setlocale(LC_ALL,"portuguese_Brazil");
int i;
struct cadastro al[qtd];
for (i=0; i<qtd; i++){
printf("Cadastro do %dº aluno\n", i+1);
printf("-----------------\n");
printf("Informe o nome: ");
scanf("%s", &al[i].nome);
printf("Informe a matrícula: ");
scanf("%d", &al[i].matricula);
printf("Informe a primeira nota: ");
scanf("%f", &al[i].nota1);
printf("Informe a segunda nota: ");
scanf("%f", &al[i].nota2);
printf("\n\n");
}
for (i=0; i<qtd; i++){
printf("Exibindo cadastro do %dº aluno\n", i+1);
printf("--------------------\n");
printf("Nome: %s\n", al[i].nome);
printf("Matrícula: %d\n", al[i].matricula);
printf("Média: %.2f\n", (al[i].nota1 + al[i].nota2)/2);
printf("\n\n");
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment