In this tutorial you will learn about the C Program to Print Good Morning Evening Night according to Time and its application with practical example.
C Program to Print Good Morning Evening Night according to Time
In this tutorial, we will learn to create a C program that will Print Good Morning Evening Night according to Time in C programming.
Before starting with this tutorial we assume that you are best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- Conditional Statements in c programming.
A program that will Print Good Morning, Evening, Night according to Time
As we all know the C programming is a very powerful programming language.With the help of which we can take input in all datatypes. In today’s program, we will create a c program that will take the input in the form of an integer, and then it will calculate the time and Print Good Morning, Evening, Night according to Time.
With the help of this program, we can Print Good Morning, Evening, Night according to Time.
1. Declare the variables for the program.
2. Take the input time from the user.
3. Pass that time to a conditional statement.
4. Calculating the time.
5. Print the greeting message.
6. End the program.
Program to Print Good Morning Evening Night according to Time:-
//declaring the variable for the program to take the input time
//taking input time from the user in integer form
printf("Enter the time (1-24): ");
//checking the time and printing the output
if(t>0 && t<=3)
//printing Good night
else if(t>3 && t<12)
//printing Good morning
//printing Good NOON
else if(t>12 && t<=15)
//printing Good afternoon
else if(t>15 && t<20)
//printing Good EVENING
else if(t>=20 && t<=24)
//printing DEFAULT TIME
In the above program, we have first initialized the required variable.
- t = it will hold the integer value for time input.
Input strings from the user.