Solution of URI 1040::Average 3
Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problem, you will inform me by comment.
#include <stdio.h>
int main()
{
float N1,N2,N3,N4,avg,avg1;
scanf("%f%f%f%f",&N1,&N2,&N3,&N4);
avg=(((N1*2)+(N2*3)+(N3*4)+(N4*1))/10);
printf("Media: %.1f\n",avg);
if(avg>=7.0) {
printf("Aluno aprovado.\n");
}
else if(avg<5.0) {
printf("Aluno reprovado.\n");
}
else if (avg>=5.0 || avg<=6.9) {
printf("Aluno em exame.\n");
scanf("%f",&avg1);
printf("Nota do exame: %.1f\n",avg1);
printf("Aluno aprovado.\n");
printf("Media final: %.1f\n",(avg+avg1)/2);
}
return 0;
}
No comments