C program to find the sum of first and last digit in the given number

#include<stdio.h>
int main()
{
    int n,i,num,sum;
    printf("enter the number \n\n");
    scanf("%d",&n);
    int first,last;
    num=n;
    last=n%10;
    while(n>9)
    {
        n=n/10;
    }
    first=n;
    sum=first+last;
    printf("\nthe first and last number in %d is:%d and %d\n",num,first,last);
    printf("\n The sum of first and last digit is : %d\n",sum);

}
Output:
C program to find the sum of first and last digit in the given number

Comments