Q:

Write a C program that reads an integer between 1 and 12 and print the month of the year in English

0

Write a C program that reads an integer between 1 and 12 and print the month of the year in English

Test Data :
Input a number between 1 to 12 to get the month name: 8
Expected Output:
August

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>
int main() {
	int mno;
	printf("\nInput a number between 1 to 12 to get the month name: ");
	scanf("%d", &mno);
	switch(mno) {
		case 1 : printf("January\n"); break;
		case 2 : printf("February\n"); break;
		case 3 : printf("March\n"); break;
		case 4 : printf("April\n"); break;
		case 5 : printf("May\n"); break;
		case 6 : printf("June\n"); break;
		case 7 : printf("July\n"); break;
		case 8 : printf("August\n"); break;
		case 9 : printf("September\n"); break;
		case 10 : printf("October\n"); break;
		case 11 : printf("November\n"); break;
		case 12 : printf("December\n"); break;
		default : printf("Input a number between 1 to 12.");
	}
	return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Basic Declarations and Expressions exercises

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a C program that prints all even numbers bet... >>
<< Write a C program that reads two integers and chec...