With outputs Write a program that exits when the user inputs
With outputs.
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., \'\ \', then do not print anything; otherwise, print the prompt again.Solution
#include <stdio.h>
 #include <stdlib.h>
int main()
 {
 char c;
 printf(\"Would you like to exit (Y/N):\");
 c = getchar();
 if (tolower(c) == \'y\'){
 exit(0);
 }
 else if (c == \'\ \'){
 printf(\" \");
 }
 else{
 putchar(c);
    printf(\"\ \");
 }
 return 0;
 }

