Q:

Write C program to find first and last digit of any number

0

Write C program to find first and last digit of any number

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>
 
main()
{
    int num, last ;
    printf("Enter any number : ");
    scanf("%d", &num);
 
    last = num%10;
    printf("The last digit of entered number: %d\n", last);
 
    while(num>=10)
    {
        num = num/10;
    }
 
    printf("The first digit of entered number: %d\n", num);
}

Result:

Enter any number : 123456

The last digit of entered number: 6

The first digit of entered number: 1

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write C program to calculate product of digits of ... >>
<< Write C program to find the sum of first and last ...