I am writing a simple code which takes a character from the user and prints it, if the character is q, then the loop breaks. but the output I am getting prints the print statement twice and second time its printing nothing please have a look at the image. Why is it printing twice?
#include<stdio.h>
void main()
{
char c;
printf("Enter a character: ");
c=getchar();
while(c!='q')
{
putchar(c);
printf("\nEnter a character: ");
c=getchar();
}
}