switch case multiple range in C -
switch (mark / 10) { case 10: case 9: case 8: printf("the grade a.\n"); break; case 7: printf("the grade b.\n"); } } }
mark >= 75 gives grade a.
may know how edit case 7 can detect 75 , above grade a. thank you!
if plan use gcc can use switch ranges:
https://gcc.gnu.org/onlinedocs/gcc/case-ranges.html
switch (mark) { case 75 ... 100: printf("the grade a.\n"); break; case 70 ... 74: printf("the grade b.\n"); break /*....*/ }
Comments
Post a Comment