Program in C++ to display the name of the day in a week

Program in C++ to display the name of the day in a week, depending upon the number entered through the keyboard.

The program will accept integer value between 1 and 7. Depending on the number entered, the program will display the name of the day as follows:
1 => “Monday”
2 => “Tuesday”
3 => “Wednesday”
4 => “Thursday”
5 => “Friday”
6 => “Saturday”
7 => “Sunday”

/*
Program Name: Program in C++ to display the 
name of the day in a week, depending upon 
the numberentered through the keyboard
Author: LearnCPPOnline.com
*/

#include <iostream>
#include "conio.h"
using namespace std;

void main() {

 int day;

 cout << "Enter a number between 1 to 7: ";
 cin >> day;

 switch(day)
 {
 case 1:
	 cout << "Monday" << endl;
	 break;
 case 2:
	 cout << "Tuesday" << endl;
	 break;
 case 3:
	 cout << "Wednesday" << endl;
	 break;
 case 4:
	 cout << "Thursday" << endl;
	 break;
 case 5:
	 cout << "Friday" << endl;
	 break;
 case 6:
	 cout << "Saturday" << endl;
	 break;
 case 7:
	 cout << "Sunday" << endl;
	 break;
 default:
	 cout << "Number entered is invalid" << endl;
 }

 getch();

}

Output:

Enter a number between 1 to 7: 6
Saturday

Note: The above program is written and tested using Microsoft Visual Studio 2008

You may also like...

1 Response

  1. sam says:

    thnx bro!!!!!

Leave a Reply

Your email address will not be published.

%d bloggers like this: