1
I’m creating a program that reads the student’s name, number of fouls, 3 grades and returns if the student has passed, flunked for foul or flunked for average, knowing that the foul limit is 15, the minimum grade for approval is 7 and that failure for lack overrides failure on average.
But it turns out that after printing on the "type in the number of absences" screen, the program does not expect me to enter a number, but ends the program immediately. What’s the mistake?
#include <stdio.h>
int main() {
char nome;
int f;
float n1,n2,n3;
float mf=(n1+n2+n3)/3;
printf("Digite o nome do aluno: \n");
scanf("%c", &nome);
printf("Digite o numero de faltas do aluno: \n");
scanf("%d", &f);
if (f > 15)
printf("Aluno reprovado por falta. \n");
else {
printf("Digite a primeira nota do aluno: \n");
scanf("%f", &n1);
printf("Digite a segunda nota do aluno: \n");
scanf("%f", &n2);
printf("Digite a terceira nota do aluno: \n");
scanf("%f", &n3);
if(mf>=7)
printf("Aluno aprovado! \n");
else
printf("Aluno reprovado por media. \n");
}
return 0;
}
You’re ordering to read only one character, need to ask for one string, and of course, first you need to allocate memory to her.
– Maniero
how do I do that?
– Cauã Vilte