Wednesday, August 24, 2016

C program to display Good morning message based on given time.

Conversion of flowchart to C program: Display Good morning message based on given time.

#include<stdio.h>
int main()
{
     int time;
     printf("Enter your time:");
     scanf("%d",&time);
     if(time < 12)
     {
           printf("Good Morning...");
     }
     return 0;
}

Output of the Program:

Enter your time:10
Good Morning...

10 comments:

  1. write a program to accept name and display the name with good morning

    ReplyDelete
    Replies
    1. Dear Manish,

      C program for accepting name and display name with good morning message is posted today at following URL:

      http://cprogrampracticals.blogspot.in/2016/12/accept-name-and-display-name-with-good.html

      Thanks and regards,

      Delete
    2. Creat a program that will allow the user to enter a country and the program will display the message good

      Delete
  2. There is mistake how it can be <12

    ReplyDelete
    Replies
    1. Thanks for your input.

      As this is basic program to introduce use of "if statement" and "< operator" hence more conditions are not added in the program. We can always add more conditions by adding more statements like if(time > 4 && time < 12) to display appropriate greeting message.

      Delete
  3. This is great I prefer you add more statements like if(time >4 && time < 12) that will be better

    ReplyDelete
    Replies
    1. Thank you for your inputs. Updated program will be uploading soon.

      Delete
  4. Please write the program by system time

    ReplyDelete