Use for loop as the user selection's controller
#include <stdio.h> #include <conio.h> int main(void) { int i; char ch; ch = 'a'; /* initial value */ for(i=0; ch != 'q'; i++) { printf("pass: %d\n", i); ch = getchar(); } return 0; }