Program to identify day of week

0 Suresh Chand April 2, 2021

In this example, You will learn a program to identify day of week using c++ programming language. We will use a switch case for that. If the user input day between [1-7] then we will print day otherse that will be invalid day.

First we will ask user for day between 1 to 7 then we will use switch case to match the condition. We will check 7 condition inside the switch case.

To understand this example, You must have knowledge in following topics

Let’s look and code to make clear concepts

Example: Program to identify day of week

#include <iostream>
using namespace std;

int main(){

    int day;

    cout << "Enter day of week between 1 to 7 : ";
    cin >> day;

    switch(day)
    {
        case 1:
            cout << "The day is Sunday" << endl;
            break;

        case 2:
            cout << "The day is Monday" << endl;
            break;

        case 3:
            cout << "The day is Tuesday" << endl;
            break;

        case 4:
            cout << "The day is Wednesday" << endl;
            break;

        case 5:
            cout << "The day is Thursday" << endl;
            break;

        case 6:
            cout << "The day is Friday" << endl;
            break;

        case 7:
            cout << "The day is Saturday" << endl;
            break;

        default:
            cout << "Invalid Options" << endl;
    }

    return 0;
}

The output of above program is

Program to identify day of week
Output
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Join Our Newsletter Now

Get the latest tutorials, examples and projects updates.

Ads Block Detector Powered by codehelppro.com

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Disable Ad Block

Want Same System