Noob here. I cannot seem to fix the "misplaced else" error on the code below. This code should collect and compute for term grade and give remarks depending on the score. Any help is appreciated.
#include<conio.h>
#include<stdio.h>
main()
{
char name[20];
int exam,q1,q2,q3,ass,sw,att,avgq,CS,TG;
clrscr();
printf("Name: ");
gets(name);
printf("\nExam: ");
scanf("%d",&exam);
printf("\nQuiz #1: ");
scanf("%d",&q1);
printf("\nQuiz #2: );
scanf("%d",&q2);
printf("\nQuiz #3: ");
scanf("%d",&q3);
printf("\nAssignment: ");
scanf("%d",&ass);
printf("\nSeatwotk: ");
scanf("%d",&sw);
printf("\nAttendance: ");
scanf("%d",&att);
CS=(0.4*ass)+(0.4*sw)+(0.2*att); //class standing//
avgq=(q1+q2+q3)/3; //average quiz//
TG=(0.4*exam)+(0.3*avgq)+(0.3*CS); //term grade//
if(TG>=90)
printf("Term Grade: %d",TG);
printf("Remarks: EXCELLENT");
else if (TG>=80 && TG<=89)
printf("Term Grade: %d",TG);
printf("Remarks: SATISFACTORY");
else if (TG>=76 && TG<=79)
printf("Term Grade: %d",TG);
printf("Remarks: GOOD");
else if (TG==75)
printf("Term Grade: %d",TG);
printf("Remarks: PASSING");
else if (TG<74)
printf("Term Grade: %d",TG);
printf("Remarks: FAILED");
else
printf("Invalid Input. Try again");
getch();
return 0;
}
Aucun commentaire:
Enregistrer un commentaire