Make a function TimeToGreeting that takes in time as a parameter and prints Good
ID: 3601989 • Letter: M
Question
Make a function TimeToGreeting that takes in time as a parameter and prints Good Morning, Afternoon, Evening... Complete by next class (Monday). Stretch goal: modify TimeToGreeting to include a character to indicate the language (e.g. 'E' -English, S- Spanish, 'F' - French. (you can used Google translate to get the proper equivalent, or just say "French version of Good Morning What is your name? Joe What time is it? 0900 Good morning, Joe. >timeGreetings What is your name? Laura What time is it? 1400 Good afternoon, Laura.Explanation / Answer
#include "stdio.h"
int main(void) {
char name[20];
int time;
printf("Enter your name?");
scanf("%s",&name);
printf("What time is it ?");
scanf("%d",&time);
if(time<1200)
printf("Good Morning, %s.",name);
else if(time<1600)
printf("Good Afternoon, %s.",name);
else
printf("Good Evening, %s.",name);
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.