Skip to main content

Sample C Program To Display The Days In A Week.


#include <stdio.h>
#include <conio.h>
void main()
{

char ch;
clrscr();
printf(" Enter m for Monday\n t for Tuesday\n w for Wednesday\n h for Thursday\n f for Friday\n s for Saturday\n u for Sunday ");

scanf(" %c ", &ch);

switch(ch)
   {
      case 'm':
      case 'M':
      printf("The day is Monday");
      break;

      case 't':
      case 'T':
      printf("The day is Tuesday");
      break;

      case 'w':
      case 'W':
      printf("The day is Wednesday");
      break;

      case 'h':
      case 'H':
      printf("The day is Thursday");
      break;

      case 'f':
      case 'F':
      printf("The day is Friday");
      break;

      case 's':
      case 'S':
      printf("The day is Saturday");
      break;

      case 'u':
      case 'U':
      printf("The day is Sunday");
      break;

     default :
     printf("Wrong input!");
     break;
   }
getch();

}

OUTPUT:


Enter m for Monday
t for Tuesday
w for Wednesday
h for Thursday
f for Friday
s for Saturday
u for Sunday w

The day is Wednesday



ALSO READ:

-- Program To Print First Ten(10) Natural Numbers.
-- Program To Print Fibonacci Series Upto 100.
-- Program To Check Whether A Number Is Prime Or Not.
-- Program To Compute The Reverse Of A Number.
-- Program To Print A Semicolon Without Using A Semicolon.

-- Program To Display Function Without Using The Main Function.
-- Program To Print Any Print Statement Without Using Semicolon.
-- Program To Display Its Own Source Code As Its Output.
-- Program To Swap Two Strings Using strcpy() Function.
-- Program to accept a string and print the reverse of the given string.

-- Program To Get IP Address.
-- Program To Accept An Integer & Reverse It.
-- Program To Convert Given Number Of Days To A Measure Of Time Given In Years, Weeks & Days.
-- Program To Illustrate The Concept Of Unions.
-- Program To Find The Size Of A Union.

... Back To C++ Programs Index

... Back To C++ FAQ's Index

... Back To C Programs Index

... Back To C FAQ's Index

... Back To HR Interview Index

Comments