One to Five – Words

The program must accept a number from 1 to 5 and print it as a word as given below.
1 – One
2 – Two
3 – Three
4 – Four
5 – Five

Example Input/Output 1:
Input:
3

Output:
Three

Example Input/Output 2:
Input:
1

Output:
One

Python

N = int(input())
numDict = {1:'One', 2:'Two', 3:'Three', 4:'Four', 5:'Five'}
print(numDict[N])

Java

import java.util.*;
public class Hello {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        switch (N) {
            case 1:
                System.out.print("One");
                break;
            case 2:
                System.out.print("Two");
                break;
            case 3:
                System.out.print("Three");
                break;
            case 4:
                System.out.print("Four");
                break;
            case 5:
                System.out.print("Five");
                break;
        }
    }
}

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int N;
    scanf("%d", &N);
    switch(N)
    {
    case 1:
        printf("One");
        break;
    case 2:
        printf("Two");
        break;
    case 3:
        printf("Three");
        break;
    case 4:
        printf("Four");
        break;
    case 5:
        printf("Five");
        break;
    }
}

C++

#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    switch(N)
    {
    case 1:
        printf("One");
        break;
    case 2:
        printf("Two");
        break;
    case 3:
        printf("Three");
        break;
    case 4:
        printf("Four");
        break;
    case 5:
        printf("Five");
        break;
    }
    return 0;
}
Previous Article

Hot Cold or Normal

Next Article

1 to 100 - Hyphen Separated

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *