Write the query (including a printf prompt and a scanf) to get a user to enter a lowercase letter. Continue to loop (and prompt the user) until they have successfully entered an appropriate character. Do not forget to declare the variable that you are using to store the character. Do not forget to use the ampersand (&) in the scanf. Do not write an entire program.
printf and scanf functions: The C library header file, stdio.h contains the two predefined functions. The printf function display on the standard output display device. The scanf function to read the data from the standard input device, keyboard.
The format of scanf takes the format specifier and variable name with an ampersand(&). The format of printf takes the format specifier and variable name.
Declarations of C statements to define the character,and read the lower case letter .The loop continues until user enters a character other than lower case letter.
//declare variable,ch
char ch;
//prompt for user input
printf("Enter a lower case letter : ");
//read a character
scanf("%c",&ch);
//Loop continue till user enters a lower case letter
while(ch>='a' && ch<='z')
{
//prompt for user input
printf("You entered: %c\n", ch);
printf("Enter a lower case letter : ");
//clear the buffer area
fflush(stdin);
//read a character
scanf("%c",&ch);
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images