Computer Science, asked by idont0900, 3 days ago

WAP to accept number of day in a week and displaythe name of the day.I.e. Input : 3Output: WednesdayAppropriate message should be displayed for thewrong option.C++​

Answers

Answered by simonsaikia9
0

Program:

#include <iostream>

#include <string>

using namespace std;

int main()

{

   string week[7] = {"Sunday", "Monday", "Tuesday", "Wednesday",

                     "Thursday", "Friday", "Saturday"};

   int n;

   cout << "Enter the number of day: ";

   cin >> n;

   if (n > 7 || n <= 0)

   {

       cout << "Please enter the number of day correctly" << endl;

       return 0;

   }

   if (n == 7)

       cout << week[0] << endl;

   else

       cout << week[n] << endl;

}

Output: "Enter the number of day: 3

Wednesday

Attachments:
Similar questions