testing - Unexpected result c while -


hi im trying understand why if 9 or above entered judge passes shouldnt cause if says >= 4 , <= 8

thanks

while(!(judge >= 4) && (judge <= 8)) {     printf("how many judges there ? enter number between 4 - 8 \n");     scanf("%d", &judge);     while(!(judge >= 4) && (judge <= 8))     {         printf("you entered %d enter number between 4 - 8 \n", judge);         scanf("%d", &judge);         if((judge >= 4) && (judge <= 8))         {             break;         }     }  } 

it looks missing pair of parentheses in

while(!((judge >= 4) && (judge <= 8)))        ^                            ^ 

(this mistake appears in 2 places.)

by way, can avoid lot of repetition restructuring code so:

printf("how many judges there ? enter number between 4 - 8 \n"); (;;) {     scanf("%d", &judge);     if (judge >= 4 && judge <= 8) {         break;     }     printf("you entered %d enter number between 4 - 8 \n", judge); } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -