Here's my code:
What it is supposed to do is, when anything except 1 or 2 is entered, the loop will repeat. If 1 or 2 is entered, the program ends.Code:#include<stdio.h> int tix=0; main() { do { printf("\nDo you want to reserve another ticket?[1.YES 2.NO]\n"); scanf("%d", &tix); if (tix == 2) { printf("out of system"); } } while (tix < 1 || tix > 2); }
But now:
if you enter anything except "1" and "2", the program will keep repeating the message
"Do you want to reserve another ticket?[1.YES 2.NO]" but it would not stop to scan the answer. Please help.