Print Last Four Digits

The program must accept an integer N as the input. The program must print the last four digits in N as the output.

Example Input/Output 1:
Input:
23847

Output:
3847

Example Input/Output 2:
Input:
23477234

Output:
7234

Python

N = int(input())
print(N%10000)

Java

import java.util.*;
public class Hello {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.print(N % 10000);
    }
}

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int N;
    scanf("%d", &N);
    printf("%d", N % 10000);
    return 0;
}

C++

#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    cout << N % 10000;
    return 0;
}
Previous Article

Discount - 20%

Next Article

Square - Format Print

Write a Comment

Leave a Comment

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