# Sum of first and last digit in C

###### scanf() - Question 5

In this question, we will see how to input a two digit number in C programming using the scanf() function and find the sum of its first and last digit. To know more about scanf() function click on the scanf() function lesson.

**Q5)** Write a program in C to input a two digit number and find the sum of its first and last digit.

#### Program

```
#include <stdio.h>
#include <conio.h>
int main()
{
int n,fd,ld,sum;
printf("Enter a two digit number\n");
scanf("%d",&n);
fd=n/10;
ld=n%10;
sum=fd+ld;
printf("First digit=%d\n",fd);
printf("Last digit=%d\n",ld);
printf("Sum of first and last digit=%d",sum);
return 0;
}
```

#### Output

Enter a two digit number 56 First digit=5 Last digit=6 Sum of first and last digit=11