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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -