Computer Science, asked by pritymall1982, 7 months ago

8. Write a program to take the number of the month and print the name of the month according to the number
Example: Input : 4
Output: April​

Answers

Answered by anildeny
1

Answer:

Explanation:

Write a program in C to read any Month Number in integer and display Month name in the word.

Pictorial Presentation:

Read month number and display month name

Sample Solution:

C Code:

#include <stdio.h>

void main()

{

  int monno;

  printf("Input Month No : ");

  scanf("%d",&monno);

  switch(monno)

  {

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("invalid Month number. \nPlease try again ....\n");

       break;

Answered by Equestriadash
4

Note that the following codes have been written in Python.

choice = "Yes"

while choice == "Yes":

   num = int(input("Enter a number: "))

   if num == 1:

       print()

       print("January")

   elif num == 2:

       print()

       print("February")

   elif num == 3:

       print()

       print("March")

   elif num == 4:

       print()

       print("April")

   elif num == 5:

       print()

       print("May")

   elif num == 6:

       print()

       print("June")

   elif num == 7:

       print()

       print("July")

   elif num == 8:

       print()

       print("August")

   elif num == 9:

       print()

       print("September")

   elif num == 10:

       print()

       print("October")

   elif num == 11:

       print()

       print("November")

   elif num == 12:

       print()

       print("December")

   else:

       print("There are only 12 months.")

   print()

   choice = input("Would you like to go again? [Yes/No]: ")

   print()

Output:

Attachments:
Similar questions