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 "); }
4 odpowiedzi
+ 4
Remove #include <conio.h>
Add closing parentheses for the conditions of the two `else if` branches.
+ 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
+ 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 ");
}