I believe, I need two loops for this..but I just can't make it out no matter how hard I try. So I guess I need help!
Here is the code...:
Code:#include <stdio.h> #include <stdlib.h> int main() { int counterH = 0; int counterN = 0; int mark; int confirmExit; printf("Please input student mark: "); scanf("%d", &mark ); while ( mark <= 100 ) { if ( mark >= 85 ) { puts ("H"); counterH++; } else if ( mark >= 75 ) puts ("D"); else if ( mark >= 65 ) puts ("P"); else if ( mark >= 50 ) puts ("C"); else if ( mark >= 0 ) { puts ("N"); counterN++; } printf("Please input student mark: "); scanf("%d", &mark ); } }/* End Main*/
So the problem here, is that I don't know how to insert the other condition which is to exit if the user wants to.
Here's the full question:
1) get one student’s mark (keep asking for input if the input is more than 100)
2) decide and display which grade the mark is in ( make a series of if / else decisions)
3) add 1 (one) to the corresponding counter for grade HD and grade N
4) ask if this is the last student
5) if not the last student, return to the start to get the next student’s mark
I got (1),(2) and (3) right. I don't know how to deal with (4) and (5) =(
I appreciate all the help!
Regards,
Sam