My error with line 20 if strcmp and line 75 getch show that undeclared,somebody
can help me.TQ!
Below is my error result:
Code:#include <stdio.h> main () { int credit_hour1,credit_hour2, totalcredithours; char fix_grade[3]="A"; char grade1[3]; char grade2[3]; float calculation1, calculation2, totalcalculation,GPA; printf("Please enter your Grade for subject_1 :"); scanf("%s",&grade1); printf("Please enter your credit hour for subject_1 :"); scanf("%d",&credit_hour1); printf("Please enter your Grade for subject_2 :"); scanf("%s",&grade2); printf("Please enter your credit hour for subject_2 :"); scanf("%d",&credit_hour2); if(strcmp(grade1,"A" ) == 0) calculation1 = 4.00 * credit_hour1; if (strcmp(grade1, "A-")== 0) calculation1 = 3.67 * credit_hour1 ; if(strcmp(grade1,"B+" ) == 0) calculation1 = 3.33 * credit_hour1; if (strcmp(grade1, "B")== 0) calculation1 = 3.00 * credit_hour1; if(strcmp(grade1,"B-" )== 0) calculation1 = 2.67 * credit_hour1; if (strcmp(grade1, "C+")== 0) calculation1 = 2.33 * credit_hour1; if(strcmp(grade1,"C" ) == 0) calculation1 = 2.00 * credit_hour1; if (strcmp(grade1, "C-")== 0) calculation1 = 1.67 * credit_hour1; if(strcmp(grade1,"D+" ) == 0) calculation1 = 1.33 * credit_hour1; if (strcmp(grade1, "D")== 0) calculation1 = 1.00 * credit_hour1; if(strcmp(grade1,"F" ) == 0) calculation1 = 0.00 * credit_hour1; else if(strcmp(grade2,"A" ) == 0) calculation2 = 4.00 * credit_hour2; if (strcmp(grade2, "A-")== 0) calculation2 = 3.67 * credit_hour2 ; if(strcmp(grade2,"B+" ) == 0) calculation2 = 3.33 * credit_hour2; if (strcmp(grade2, "B")== 0) calculation2 = 3.00 * credit_hour2; if(strcmp(grade2,"B-" ) == 0) calculation2 = 2.67 * credit_hour2; if (strcmp(grade2, "C+")== 0) calculation2 = 2.33 * credit_hour2; if(strcmp(grade2,"C" ) == 0) calculation2 = 2.00 * credit_hour2; if (strcmp(grade2, "C-")== 0) calculation2 = 1.67 * credit_hour2; if(strcmp(grade2,"D+" ) == 0) calculation2 = 1.33 * credit_hour2; if (strcmp(grade2, "D")== 0) calculation2 = 1.00 * credit_hour2; if(strcmp(grade2,"F" ) == 0) calculation2 = 0.00 * credit_hour2; totalcredithours = credit_hour1 + credit_hour2 ; totalcalculation = calculation1 + calculation2 ; GPA = totalcalculation / totalcredithours ; printf("%.2f\n",totalcalculation); printf("%d\n", totalcredithours); printf("GPA %.2f\n", GPA); getch(); }



LinkBack URL
About LinkBacks



