Write a program to accept the time in 24 hour format and print message according to time like (good morning, good afternoon, good evening, good night) in C.

#include<stdio.h>
#include<conio.h>
void main()
{
  float time;
  printf("Enter the time = ");
  scanf("%f",&time);
  if(time<=12)
  {
    printf("Good Morning");
  }
  else if(time>12&&time<=18)
  {
     printf("Good Afternoon");
  }
  else if(time>18&&time<=22)
  {
    printf("Good evining");
  }
  else if(time>22&&time<=24)
  {
     printf("Good Night");
  }
getch();
}










OUTPUT :-
 
Previous Post
Next Post