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
Post a Comment