Answer to Question #298485 in C for Sasi. R

Question #298485

Write a C program to display the month of year using enumeration.



Input:


6


Output


June

1
Expert's answer
2022-02-16T08:11:06-0500
#include <stdio.h>

//January, February, March, and April, May, June, and July, August, September, October, November, December

enum Month {
    JANUARY = 1,
    FEBRUARY,
    MARCH,
    APRIL,
    MAY,
    JUNE,
    JULY,
    AUGUST,
    SEPTEMBER,
    OCTOBER,
    NOVEMBER,
    DECEMBER
};

int main() {
    // Write C code here
    
    enum Month monthOfYear = 6;
    
    switch(monthOfYear) {
        case JANUARY: printf("January");
        break;
        case FEBRUARY: printf("February");
        break;
        case MARCH: printf("March");
        break;
        case APRIL: printf("April");
        break;
        case MAY: printf("May");
        break;
        case JUNE: printf("June");
        break;
        case JULY: printf("July");
        break;
        case AUGUST: printf("August");
        break;
        case SEPTEMBER: printf("September");
        break;
        case OCTOBER: printf("October");
        break;
        case NOVEMBER: printf("November");
        break;
        case DECEMBER: printf("December");
        break;
    }

    return 0;
}

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

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS