Originally Posted by
galmca
i have looked everywhere but ican't find anything wrong anywhere..........
every line i have looked into.......
plz dave help me out........
and also tell me why is it giving me an error in line 14 as unterminated string or character constant.....even though it is correct.....
I don't get an error in line 14. Post the code again.
[edit]
Never mind; I'll do it
[/edit]
As for line 27 Here are a few lines around line 27:
Code:
else if((avmar<79)&&(avmar>60))
printf("first division");
else ((avmar<100)&&(avmar>80))
printf("honours");
This is line 26
Code:
else ((avmar<100)&&(avmar>80))
You probably meant
Code:
else if ((avmar<100)&&(avmar>80))
Now this is unnecessary logic, and line 26 could simply be
The fact is, however, your program would be syntactically correct if line 26 had a semicolon.
I sense your frustration (believe it or not --- I can feel your pain), and I know it's hard to see some types of errors when you keep looking at the same stuff for hours at a time.
It would be easier (at least it is for me) if you would use indentation and some kind of line spacing to make the code more readable
Next time you post code put code tags around it.
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
float eng, maths, de, it, c, avmar;
printf("enter the marks for english: ");
scanf("%f", &eng);
printf("enter the marks for maths: ");
scanf("%f", &maths);
printf("enter the marks for digital electronics: ");
scanf("%f", &de);
printf("enter the marks for information technology: ");
scanf("%f", &it);
printf("enter the marks for c: ");
scanf("%f", &c);
avmar=(eng + maths + de + it + c) / 5;
printf("the average marks are = %f", avmar);
if((avmar < 39) && (avmar > 0))
printf("fail");
else if((avmar < 49) && (avmar > 40))
printf("third division");
else if((avmar < 59) && (avmar > 50))
printf("second division");
else if((avmar < 79) && (avmar > 60))
printf("first division");
else
printf("honours");
getch();
}
Note there are a couple of bugs that you might not uncover by testing, so I'll give you a hint there also:
Enter 50 for all of the grades and see how they are classified
Regards,
Dave