I Have written a simple while program in C
// Online C compiler to run C online.
// Write C code in this online editor and run it.
#include <stdio.h>
typedef enum
{
false = 0,
true = 1
} bool;
int main() {
bool res = true;
while (res)
{
char choice;
printf("Success! \n");
printf("Do you want to continue(y/n): ");
scanf("%c", &choice);
if (choice == 'N' || choice == 'n')
{
res = false;
}
}
printf("Good Bye");
}
The Program run successfully but when I type Y in Do you want to continue the loop is executed twice. How Can I Solve this?