Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- //struct em global
- int i,j;
- int n = 2;
- struct RgData{
- int dia;
- int mes;
- int ano;
- };
- struct RgAluno{
- char nome[35];
- float nota[4];
- float media;
- struct RgData data;
- };
- void lerDados(struct RgAluno* p){
- float soma;
- //Leitura e armazenamento dos dados
- for(i=0; i<n; i++){
- soma = 0;
- fflush(stdin);
- printf("\nDigite o nome: ");
- gets(p[i].nome);
- printf("Digite a data de nascimento (DD MM AAAA): ");
- scanf("%d %d %d",&p[i].data.dia, &p[i].data.mes, &p[i].data.ano);
- printf("Digite as quatro notas\n");
- for(j=0; j<4; j++){
- printf("Nota %d:",(j+1));
- fflush(stdin);
- scanf("%f", &p[i].nota[j]);
- soma = soma + p[i].nota[j];
- }
- p[i].media = soma / 4;
- }
- }
- void Imprime(struct RgAluno* p){
- //Realiza a impressao
- printf("\n--- Impressao de Nomes e Notas ---\n");
- for(i=0; i<n; i++){
- printf("\n\nNome: %s", p[i].nome);
- printf("\nData de Nasc.: %d/%d/%d", p[i].data.dia, p[i].data.mes, p[i].data.ano);
- for(j=0; j<4; j++){
- printf("\nNota %d: %.2f", (j+1), p[i].nota[j]);
- }
- printf("\nMedia: %.2f", p[i].media);
- }
- }
- int main(int argc, char *argv[]) {
- struct RgAluno Aluno [5];
- lerDados(Aluno);
- Imprime(Aluno);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement