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., \'\ \', then do not print anything; otherwise, print the prompt again.

Solution

#include <stdio.h>
#include <stdlib.h>
int main(){
char input;
printf(\"Would you like to exit? Enter Y or N\");
scanf(\" %c\", &input);
while (input == \'Y\' | \'y\' ){
exit(0);
}
while (input ==\'\ \'){
}
return 0;
}

 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 \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site