Write a program that exits when the user inputs the characte
Write a program that exits when the user inputs the character \'y\'. At the start of the program, prompt the user to input a character by printing the string \"Would you like to exit? (y/n)\ \". If the input character is \'y\' or \'Y\', then the program quits; if the input character is a newline, i.e., \'In\', then do not print anything; otherwise, print the prompt again.
Solution
/* Program to loop using while */
#include <stdio.h>
#include <stdlib.h>
int main ()
{
char n=\'y\';
while (n==\'y\' || n== \'Y\'){
printf(\"Would you like to continue (y/n)\");
scanf(\"%c\",&n);
if (n==\'\ \'){
break;
}
}
return 0;
}
