Print the last digit of a
number n.
Input. One positive integer n (1 ≤ n ≤ 109).
Output. Print the last digit of the
number n.
Sample
input 1 |
Sample
output 1 |
123 |
3 |
|
|
Sample
input 2 |
Sample
output 2 |
6578 |
8 |
elementary problem
The last digit of a positive
integer n is n % 10.
Read
the input value of n.
scanf("%d",&n);
Compute and print the last
digit of the number n.
printf("%d\n",n % 10);
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
int n = con.nextInt();
int res = n % 10;
System.out.print(res);
con.close();
}
}
Read
the input value of n.
n = int(input())
Compute and print the last
digit of the number n.
a = n % 10
print(a)