Algorithm
Month
Adapted by Neilor Tonin, URI Brazil
Read an integer number between 1 and 12, including. Corresponding to this number, you must print the month of the year, in english, with the first letter in uppercase.
Input
The input contains only an integer number.
Output
Print the name of the month according to the input number, with the first letter in uppercase.
Input Sample | Output Sample |
4 |
April |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
int main()
{
int N;
scanf("%d", &N);
switch (N)
{
case 1:
printf("Januaryn");
break;
case 2:
printf("Februaryn");
break;
case 3:
printf("Marchn");
break;
case 4:
printf("Apriln");
break;
case 5:
printf("Mayn");
break;
case 6:
printf("Junen");
break;
case 7:
printf("Julyn");
break;
case 8:
printf("Augustn");
break;
case 9:
printf("Septembern");
break;
case 10:
printf("Octobern");
break;
case 11:
printf("Novembern");
break;
case 12:
printf("Decembern");
break;
default:
break;
}
}
Copy The Code &
Try With Live Editor
Input
Output
#2 #2 Code Example with Another C Programming
Code -
C Programming
#include <stdio.h>
int main()
{
int N;
scanf("%d", &N);
if(N == 1) printf("Januaryn");
else if (N == 2) printf("Februaryn");
else if (N == 3) printf("Marchn");
else if (N == 4) printf("Apriln");
else if (N == 5) printf("Mayn");
else if (N == 6) printf("Junen");
else if (N == 7) printf("Julyn");
else if (N == 8) printf("Augustn");
else if (N == 9) printf("Septembern");
else if (N == 10) printf("Octobern");
else if (N == 11) printf("Novembern");
else if (N == 12) printf("Decembern");
}
Copy The Code &
Try With Live Editor
Input
Output
#3 Code Example with C++ Programming
Code -
C++ Programming
#include <iostream>
using namespace std;
int main()
{
int d;
cin >> d;
if(d == 1) {
cout << "January" << endl;
} else if(d == 2) {
cout << "February" << endl;
} else if(d == 3) {
cout << "March" << endl;
} else if(d == 4) {
cout << "April" << endl;
} else if(d == 5) {
cout << "May" << endl;
} else if(d == 6) {
cout << "June" << endl;
} else if(d == 7) {
cout << "July" << endl;
} else if(d == 8) {
cout << "August" << endl;
} else if(d == 9) {
cout << "September" << endl;
} else if(d == 10) {
cout << "October" << endl;
} else if(d == 11) {
cout << "November" << endl;
} else if(d == 12) {
cout << "December" << endl;
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#4 Code Example with Java Programming
Code -
Java Programming
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
int N;
Scanner input =new Scanner(System.in);
switch (N =input.nextInt()) {
case 1:
System.out.print("Januaryn");
break;
case 2:
System.out.print("Februaryn");
break;
case 3:
System.out.print("Marchn");
break;
case 4:
System.out.print("Apriln");
break;
case 5:
System.out.print("Mayn");
break;
case 6:
System.out.print("Junen");
break;
case 7:
System.out.print("Julyn");
break;
case 8:
System.out.print("Augustn");
break;
case 9:
System.out.print("Septembern");
break;
case 10:
System.out.print("Octobern");
break;
case 11:
System.out.print("Novembern");
break;
case 12:
System.out.print("Decembern");
break;
default:
break;
}
}
}
Copy The Code &
Try With Live Editor
Input
Output
#5 Code Example with Python Programming
Code -
Python Programming
x=int(input())
if(x==1):
print("January")
elif(x==2):
print("February")
elif(x==3):
print("March")
elif(x==4):
print("April")
elif(x==5):
print("May")
elif(x==6):
print("June")
elif(x==7):
print("July")
elif(x==8):
print("August")
elif(x==9):
print("September")
elif(x==10):
print("October")
elif(x==11):
print("November")
elif(x==12):
print("December")
Copy The Code &
Try With Live Editor
Input
Output