Can you guys tell me the error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you guys tell me the error?

#include<stdio.h> #include<conio.h> int main() { int percentage,marks1,marks2,marks3,marks4,marks5,marks6 ; printf("Enter Your subject marks "); scanf("%d%d%d%d%d",&marks1,&marks2,&marks3,&marks4,&marks5); percentage=(marks1+marks2+marks3+marks4+marks5)/5; if((percentage<=100)&&(percentage>=90)) printf("You got A grade"); else if((percentage>=70)&&(percentage<90) printf("You got B grade"); else if ((percentage>=50)&&(percentage<70) printf("You got C grade"); else printf("Congratulations You are genius "); }

1st Jun 2021, 7:55 AM
PARV SHARMA
PARV SHARMA - avatar
4 Answers
+ 4
Remove #include <conio.h> Add closing parentheses for the conditions of the two `else if` branches.
1st Jun 2021, 8:13 AM
Ipang
+ 2
Thanks A.S. Ipang
1st Jun 2021, 8:31 AM
PARV SHARMA
PARV SHARMA - avatar
+ 1
conio is not standard header file you don't need to use mostly we using it for screen pausing in older dos version Compiler. But if u will use conio header and function which is defined in this library like getch , delay this will give you errors so avoid to use these functions. You can use system(pause>0) Your another mistakes is your marks6 variable is unused you have not used anywhere in your program it generating warning . your line number 13 in if condition you misses one round bracket closing parentheses same in next if statement. You main function type is int type so u need to use return statement .For better formatting output use escape sequence
1st Jun 2021, 8:25 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
#include<stdio.h> //#include<conio.h> int main() { int percentage,marks1,marks2,marks3,marks4,marks5; printf("Enter Your subject marks "); scanf("%d%d%d%d%d",&marks1,&marks2,&marks3,&marks4,&marks5); percentage=(marks1+marks2+marks3+marks4+marks5)/5; if((percentage<=100)&&(percentage>=90)) printf("\nYou got A grade"); else if((percentage>=70)&&(percentage<90)) printf("\nYou got B grade"); else if ((percentage>=50)&&(percentage<70)) printf("\nYou got C grade"); else printf("\nCongratulations You are genius "); }
1st Jun 2021, 8:25 AM
A S Raghuvanshi
A S Raghuvanshi - avatar