Week-Days Program || Turbo C++ || C++ || Switch Case

In this, we are going to see the topic of Switch case in C++.

This is a program of Switch Case in which we are going to print the Week days for 1 to 7 user-inputs.

The code given below can be used for TURBO C++ Compiler:-

#include<iostream.h>
#include<conio.h>

void main()
{
    clrscr();
    cout<<"\n **** This Program is of Switch Case **** \n";
    int week_day;
    cout<<"Enter a number to select the week day\n";
    cin>>week_day;

    switch (week_day)
    {
    case 1:
        cout<<"Today is Monday\n";
        break;
    
    case 2:
        cout<<"Today is Tuesday\n";
        break;

    case 3:
        cout<<"Today is Wednesday\n";
        break;

    case 4:
        cout<<"Today is Thursday\n";
        break;

    case 5:
        cout<<"Today is Friday\n";
        break;

    case 6:
        cout<<"Today is Saturday\n";
        break;

    case 7:
        cout<<"Today is Sunday\n";
        break;
    
    default:
        cout<<"Oops!! Your input is not accepted.\n";
        cout<<"Please read the instructions carefully\n";
        break;
    }
    cout<<"Thank You !!";

    getch();
}
    
    

The code given below can be used for g++/gcc Compiler:-

#include<iostream>
using namespace std;

int main()
{
    cout<<"\n **** This Program is of Switch Case **** \n";
    int week_day;
    cout<<"Enter a number to select the week day\n";
    cin>>week_day;

    switch (week_day)
    {
    case 1:
        cout<<"Today is Monday\n";
        break;
    
    case 2:
        cout<<"Today is Tuesday\n";
        break;

    case 3:
        cout<<"Today is Wednesday\n";
        break;

    case 4:
        cout<<"Today is Thursday\n";
        break;

    case 5:
        cout<<"Today is Friday\n";
        break;

    case 6:
        cout<<"Today is Saturday\n";
        break;

    case 7:
        cout<<"Today is Sunday\n";
        break;
    
    default:
        cout<<"Oops!! Your input is not accepted.\n";
        cout<<"Please read the instructions carefully\n";
        break;
    }
    cout<<"Thank You !!";

    return 0;
}
    
    

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post