Programando C - Aula 7 - Explemos de Funcao, Estrutura / Registros , Vetores, passagem de parametro
Autor: Fábio Bica | Publicado: 2013-06-21T03:23:00-07:00

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;


struct alunos{
int id;
int inscricao;
char aluno[50];
float nota1;
float nota2;
float media3;
float substituicao;
float notafinal;
};

//Globais

int i = 0;
int ide;
float media;
struct alunos notas[3];


void adicionar(int i){
notas[i];
printf("ID de gravacao: %d\n", i);
printf("Numero de inscricao: ");scanf("%d", &amp;notas[i].inscricao);
printf("Qual nome da pessoa que deseja adicionar: "); scanf("%s", &amp;notas[i].aluno);
printf("Qual a primeira nota: "); scanf("%f", &amp;notas[i].nota1);
printf("Qual a segunda nota: "); scanf("%f", &amp;notas[i].nota2);
}

float media2(int i){
notas[i];
printf("|&nbsp; ID: %d\n", notas[i].inscricao);
printf("|&nbsp; Aluno: %s\n",notas[i].aluno);
printf("|&nbsp; Nota 1: %.2f&nbsp; \n", notas[i].nota1);
printf("|&nbsp; Nota 2: %.2f&nbsp; \n", notas[i].nota2);
int media;
media = (notas[i].nota1 + notas[i].nota2)/2;
printf("|&nbsp; Media: %.2f&nbsp;&nbsp; ", media);
notas[i].media3 = media;

}

float subs(int i){

&nbsp;&nbsp;&nbsp; if(notas[i].media3&gt;=6){printf("\n\nAprovado");
&nbsp;&nbsp;&nbsp; notas[i].notafinal = notas[i].media3;}
&nbsp;&nbsp;&nbsp; if(notas[i].media3&lt;6){printf("\n\nReprovado.");
&nbsp;&nbsp;&nbsp; printf("\n Qual a nota de Substituicao: ");scanf("%f", &amp;notas[i].substituicao);


if(notas[i].nota1 &gt; notas[i].nota2){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; notas[i].notafinal = (notas[i].nota1 + notas[i].substituicao)/2;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Nota Final: %.2f ", notas[i].notafinal);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

if(notas[i].nota2 &gt; notas[i].nota1){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; notas[i].notafinal = (notas[i].nota2 + notas[i].substituicao)/2;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Nota Final: %.2f ", notas[i].notafinal);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; }

}

pesquisar(int i){
&nbsp;&nbsp;&nbsp; int i2;
printf("Digite o ID da pessoa que deseja visualizar: ");scanf("%d", &amp;i2);
notas[i2];
printf("Numero Inscricao: %d\nNome: %s \nNotaFinal: %.2f\n\n", notas[i2].inscricao, notas[i2].aluno, notas[i2].notafinal);
}


listar(int i){
&nbsp;&nbsp;&nbsp; int i3 = 0;
&nbsp;&nbsp;&nbsp; notas[i3];
&nbsp;&nbsp;&nbsp; while(i3&lt;i){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("ID: %d&nbsp; |", notas[i].inscricao);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Nome: %s\n", notas[i].aluno);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Nota Final: %.2f\n", notas[i].notafinal);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("________________________________\n");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i3++;

&nbsp;&nbsp;&nbsp; }
}




int main()
{int i2 = 0;
int op;
while(i=!i2){
printf("Qual das opcoes voce escolhe: \n 1-Adicionar Aluno \n 2-Pesquisar Aluno \n 3- Listar Alunos \n 4-Sair \n :");
scanf("%d", &amp;op);

if (op==1){system("cls");
printf("%d\n", i2);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adicionar(i2);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; system("cls");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; media2(i2);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; subs(i2);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; system("cls");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

if(op==2){system("cls");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pesquisar(i2);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++;
}

if(op==3){system("cls");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; listar(i2);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++;


}



i2++;
}

}