What would be output based on the user input shown below, given that variable \"
ID: 3768500 • Letter: W
Question
What would be output based on the user input shown below, given that variable "feeling" is a declared as a char. Please place your answer where indicated in the box below (this is a program segment, not a complete program; do not say error or no output).
printf ("How do you feel (G=Good, S=Sick, T=Tired): ");
scanf ("%c", &feeling);
switch (feeling)
{
case 'S': printf ("Take 2 aspirin. ");
printf ("Call me in the morning. ");
break;
case 'T': printf ("Don't stay up late. ");
printf ("Get some sleep! ");
break;
case 'G': printf ("I'm glad for you. ");
break;
default: printf ("**Invalid Feeling**");
break;
}
Program execution #1:
How do you feel (G=Good, S=Sick, T=Tired): T
(The user entered "T")
Program output would be:
Program execution #2:
How do you feel (G=Good, S=Sick, T=Tired): G
(The user entered "G")
Program output would be:
Explanation / Answer
For input T:
Don't stay up late.
Get some sleep!
For input 'G':
I'm glad for you.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.