#include<stdio.h>
#include<stdlib.h>

int ask_to_exit()
{
    int choice;

    do
    {
        printf("Do you want to continue?(y/n):");
        choice = fgetc(stdin);

        while (fgetc(stdin) != '\n');

        if (choice == 'y') {
            return 0;
        } else if (choice == 'n') {
            return 1;
        } else {
            printf("Invalid choice!\n");
        }
    } while (1);
}
int main()
{
	int exit = 0;
	while(!exit)
	{
		exit = ask_to_exit();
	}
	puts("Exiting...");
	return 0;
}
