Tuesday, 17 June 2014

C++ program to print days from Monday to Sunday corresponding to number 1 to 7



Here is a C++ program to print days from Monday to Sunday corresponding to number 1 to 7


 SOURCE CODE OUTPUT
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    int n;
    cout<<"Enter number (1-7)=";
    cin>>n;
    switch (n)
    {
        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<<"not valid";
    }
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment