Code For Alls..!

get the code!!

Saturday 7 October 2017

Print Calendar Month in Words

                                            Print Calendar Month in Words
The program must accept an integer value N and print the corresponding calendar month in words.
1 - January, 2 - February, .... , 11 - November, 12 - December
If any value apart from 1 to 12 is passed as input, the program must print "Invalid Input".
Input Format:
The first line denotes the value of N.
Output Format:
The first line contains the output as per the description. (The output is CASE SENSITIVE).
Boundary Conditions:
1 <= N <= 12
Example Input/Output 1:
Input:
5
Output:
May
Example Input/Output 2:
Input:
12
Output:
December
Example Input/Output 3:
Input:
105
Output:
Invalid Input
program:
#include<stdio.h>
#include <stdlib.h>

int main()
{
int n;
scanf("%d",&n);
    switch(n)
    {
        case 1:
            printf("January");
            break;
        case 2:
            printf("February");
            break;
        case 3:
            printf("March");
            break;
        case 4:
            printf("April");
            break;
        case 5:
            printf("May");
            break;
        case 6:
            printf("June");
            break;
        case 7:
            printf("July");
            break;
        case 8:
            printf("August");
            break;
        case 9:
            printf("September");
            break;
        case 10:
            printf("October");
            break;
        case 11:
            printf("November");
            break;
        case 12:
            printf("December");
            break;
        default:
            printf("Invalid Input");
    }

}

No comments:

Post a Comment