how to write a programme that read mark and grade to this range?
F 0-45
D 46-50
C 51-60
B 61-80
A 81-100
the programe shoud continue reading the marks and grade it until user key in "N" for no. then the programe will stop the loop.
Help with simple while loop programme c code?
is this part of an assignment?
Reply:Here it is for you:
/*Begin C program*/
#include %26lt;stdio.h%26gt;
main()
{
int grade, loop=1;
while(loop){
printf("Enter grade: ");
scanf("%d", %26amp;grade);
if(grade%26gt;80)
printf("A");
else if(grade%26gt;60)
printf("B");
else if(grade%26gt;50)
printf("C");
else if(grade%26gt;45)
printf("D");
else
printf("F");
printf("\nRepeat [Y/N]? ");
scanf("%*c%c", %26amp;grade); /*Yes, chars/ints are interchangeable*/
if(grade=='n'||grade=='N')
loop=0;
} /*while*/
} /*main*/
/*End C program*/
Reply:interesting question i'll have to wait to find out
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment