I have the following block of code...
I wanted to keep prompting the user for this question until the integer "1" is entered. I don't think the IF statement is ever true regardless if I were to enter a 1, or not. Simply because I am comparing the input from the user with an integer, which i believe is the problem. But.. how would i be able to fix this?Code:int counter2 = 0; while(counter2 < 1) { printf("What time of the day were you travelling at? Was it at the peak scanf("%d", &timeofday); if(timeofday == 1 || timeofday ==2) { counter2 = counter2 + 1; } else printf("ERROR; incorrect input."); }




Reply With Quote