Answer to Question #283016 in C++ for foden

Question #283016

Write a program to display the month name as the user enters a number from 1 to 12 .Hint use switch statement…(1-september,2-october,…..)




1
Expert's answer
2021-12-27T08:38:16-0500
#include<iostream>

using namespace std;

int main()
{
	int month;
	cout << "Please, enter a number from 1 to 12: ";
	cin >> month;
	switch (month)
	{
		case 1:
		{
			cout << "september";
			break;
		}
		case 2:
		{
			cout << "october";
			break;
		}
		case 3:
		{
			cout << "november";
			break;
		}
		case 4:
		{
			cout << "december";
			break;
		}
		case 5:
		{
			cout << "january";
			break;
		}
		case 6:
		{
			cout << "february";
			break;
		}
		case 7:
			cout << "march";
		{
			break;
		}
		case 8:
		{
			cout << "april";
			break;
		}
		case 9:
		{
			cout << "may";
			break;
		}
		case 10:
		{
			cout << "june";
			break;
		}
		case 11:
		{
			cout << "july";
			break;
		}
		case 12:
		{
			cout << "august";
			break;
		}
		default:
			cout << "Undefined selection";
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment