Can anyone help me with this, most probably easy problem to must of you.
"Write a program that uses a combination of a for statement and a switch statement to loop over the months of this year, labelled by 1,2...12, and print the number of days i.e. 30 for Apr.,Jun.,Sep. and Nov., 29 for Feb. and 31 for the rest. You will need two case statements
and a default: Your output can be of the form:
Month 1 has 31 days
Month 2 has 28 days
What I really need to know is how can I write a for loop which points specific numbers to a certain switch case, i.e, if when x=7 I want it to output case 2. Here is a sample of the code I have wrote
// Calendar for the year
for(int m=1; m<=12; m++)
cout<<" has 31 days"<<endl;
cout<<" has 30 days"<<endl;
cout<<" has 28 days"<<endl;
I have even tried using the math function || for the cases but was unsuccessful. I'm sure there is something simple I'm missing, so I would be grateful for some help.