Write a program to accept a number and print the last digit.
Input= 285
Output = 5
Answers
Answered by
0
Answer:
int ld=n%10;
System.out.println("Last digit of the number=": + ld);
Explanation:
Before this, you must accept the number into the integer n.
n%10 gives the modulus of n/10, that is, the amount that will be left over after the division (reminder). This will be the last digit.
Answered by
0
Answer:
#include<iostream>
using namespace std;
int main()
{
int r,n;
cin>>n;
r=n%10;
cout<<r;
}
Similar questions