I try to write a program in C using the loop that repeated until a specific character is inputted from the keyboard. Here's my code:
#include <stdio.h>
main ()
{
    char option;
    do
        {
            printf("Enter q to quit: ");
            option = getchar ();
        }
    while (option != 'q');
}
I've also tried with the scanf () but the result always the same. Here the output after I tried to test the program:
Enter q to quit: 3
Enter q to quit: Enter q to quit: 2
Enter q to quit: Enter q to quit: 1
Enter q to quit: Enter q to quit: q
Can anyone explain to me why the "Enter q to quit : " always appear twice and how can I fix it?
 
     
     
     
     
    