Computer Science, asked by Ruler12345, 9 months ago

Write a program to accept a number and print the last digit.
Input= 285
Output = 5

Answers

Answered by Samton
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 Yamini1999
0

Answer:

#include<iostream>

using namespace std;

int main()

{

int r,n;

cin>>n;

r=n%10;

cout<<r;

}

Similar questions