Write C++ program to print day of week name using switch case

Introduction

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.

#include <iostream>
 
using namespace std;
 
int main()
{
    int weeknumber;
 
   //Reading week no from user
   cout<<"Enter week number(1-7): ";
   cin>>weeknumber;
 
    switch(weeknumber)
    {
        case 1: cout<<"Monday";
            break;
        case 2: cout<<"Tuesday";
            break;
        case 3: cout<<"Wednesday";
            break;
        case 4: cout<<"Thursday";
            break;
        case 5: cout<<"Friday";
            break;
        case 6: cout<<"Saturday";
            break;
        case 7: cout<<"Sunday";
            break;
        default: cout<<"Invalid input! Please enter week no. between 1-7.";
    }
 
    return 0;
 
}
 

Result

Write C++ program to print day of week name using switch case
Write C++ program to print day of week name using switch case

2 thoughts on “Write C++ program to print day of week name using switch case”

Leave a Comment