Sunteți pe pagina 1din 2

CLA: Programming

Essentials in C C++ INSTITUTE - PROGRAM YOUR FUTURE

Lab 4.1.4.1 Switch: part 1


Objectives
Familiarize the student with:

Working with the switch-case statement


Printing on screen

Scenario
Write a program that asks for the number of a month from the user and prints the name of that month on the screen. When the number
does not correspond to a month (less than 1 or greater than 12), the program prints: "Error: no such month in my calendar." If you can't
remember all the names (and of course to speed up your programming), here is a list:

1 : January
2 : February
3 : March
4 : April
5 : May
6 : June
7 : July
8 : August
9 : September
10 : October
11 : November
12 : December

Your version of the program must print the same result as the expected output.

#include <stdio.h>

int main()
{
/* your code */
return 0;
}

Example input
12

Example output
December

Example input
2

Example output
February

Example input
15

2016 C++ Institute. All rights reserved. Last updated: September 27, 2016 | www.cppinstitute.org Page 1 of 2
Lab 4.1.4.1 Switch: part 1

Example output
Error: no such month in my calendar.

2016 C++ Institute. All rights reserved. Last updated: September 27, 2016 | www.cppinstitute.org Page 2 of 2

S-ar putea să vă placă și