Print Unit Digit

The program must accept a number and print its unit digit.

Example Input/Output 1:
Input:
72

Output:
2

Example Input/Output 2:
Input:
65

Output:
5

Python

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

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 % 10);
    }
}

C

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

C++

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

Leave a Reply

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

More posts. You may also be interested in.