C program to find last digit (unit digit) of a number.
Extract the last digit from a number
Program:
#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
int num,last_digit;
clrscr();
printf("Enter a number: ");
scanf("%d",&num);
last_digit=num%10;
printf("the last digit is: %d",abs(last_digit));
getch();
}
Output 1:
Enter a number: 203
the last digit is: 3
Output 2:
Enter a number: -607
the last digit is: 7
👌🏻👌🏻👌🏻👌🏻👍🏻
ReplyDelete👏
ReplyDelete