Problem 23: Months Name

Write a program that takes an integer as input [ 1 – 12 ] and print the corresponding month name. [If user gives input ‘1’ you should print ‘January’]

 

1,865 total views, 2 views today

Comments

comments

6 thoughts on “Problem 23: Months Name”

  1. #include
    int main()
    {
    char str[12][20]={“January”,”February”,”March”,”April”,”May”,”June”,”July”,”August”,”September”,”October”,”November”,”December”};
    int n;
    while(scanf(“%d”,&n)&&n<12){
    printf("%s\n",str[n-1]);
    }
    return 0;
    }

  2. k;
    case 4:printf(“Aprill\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;
    }

    return 0;
    }

  3. #include
    int main()
    {
    int num;

    printf(“\nEnter the number between 1 – 12\n”);
    scanf(“%d”,&num);

    switch(num)
    {
    case 1:printf(“January\n”);
    break;
    case 2:printf(“February\n”);
    break;
    case 3:printf(“March\n”);
    break;
    case 4:printf(“Aprill\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 4:printf(“Aprill\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;
    }

    return 0;
    }

  4. #include
    int main()
    {
    int num;

    printf(“\nEnter the number between 1 – 12\n”);
    scanf(“%d”,&num);

    switch(num)
    {
    case 1:printf(“January\n”);
    break;
    case 2:printf(“February\n”);
    break;
    case 3:printf(“March\n”);
    break;
    case 4:printf(“Aprill\n”);
    break;
    case 5:printf(“May\n”);
    break;
    case 6:printf(“June\n”);
    break;
    case 7:printf(“July\n”);
    break;
    case 8:printf(“August\);
    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;
    }
    return 0;
    }

  5. #include
    int main()
    {
    int n;
    printf(“Enter number 1 to 12\n”);
    scanf(“%d”,&n);
    if(n==1){
    printf(“January”);
    }
    else if(n==2){
    printf(“February”);
    }
    else if(n==3){
    printf(“March”);
    }
    else if(n==4){
    printf(“April”);
    }
    else if(n==5){
    printf(“May”);
    }
    else if(n==6){
    printf(“June”);
    }
    else if(n==7){
    printf(“july”);
    }
    else if(n==8){
    printf(“August”);
    }
    else if(n==9){
    printf(“September”);
    }
    else if(n==10){
    printf(“October”);
    }
    else if(n==11){
    printf(“November”);
    }
    else{
    printf(“December”);
    }
    }

  6. #include
    int main()
    {
    int s;
    scanf(“%d”,&s);
    switch(s)
    {
    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\n”);

    }
    return 0;
    }

Leave a Reply

Your email address will not be published.