I want the program to do this this:
The application requires that the user enters integer mark between 0 and 100 (both marks inclusive). If the mark entered by the user is negative (below 0) or above 100, the application prints error message – “Error – marks are out of range: marks must be between 0 and 100 both marks inclusive”.
When user enters marks between 90 and 100 the letter grade assigned is ‘A’. When the user enters marks between 80 and 89, the application assigns the letter grade as ‘B’. When the user enters marks between 70 and 79, the letter grade assigned is ‘C’. When user enters marks between 60 and 70, user gets letter grade of ‘D’ and mark below 60 means letter grade of ‘F’.
However, when i do the code it wont work how i want the program to work and i dont know whats the problem.
The only parts that work the way i want it to is from 100- 90 and from 0- 60.
Whenever I try to input the other numbers the program just breaks from the loop.
I really need help.
Thanks that fixed one of the problems. The second problem is that whenever i input any number from 89- 60 the program just loops without showing the printf statements... cant really figure it out
and the coding on lines 60- 63 is the input key to exit the program... maybe i should fix it up
Your problem is that a mark can not be <=80 AND >=89 at the same time.
Look at how you used to put the biggest mark first, but switched that around starting at line 29.
You can either switch the numbers around or code it this way:
1 2 3 4 5
elseif (mark>=80 && mark<=89)
{
printf("\n\n\n\tYou entered the mark as:\t\t%d", mark);
printf("\n\n\tYour calculated grade is:\t\tB\n");
system("pause");
You should also rewrite it in a way that "You entered..." and "Your calculated..." is only present once.
Your code has useless repetitions and that is something you'll want to avoid as much as possible when writing more complex programs. It can lead to mistakes, especially if you ever need to go back and change the code a little bit.