Add two digits of a number - C Program

C program to read 2 digit number and print sum of both digit.

Solution:

In this program, we will learn how to calculate sum of two digits of a number.

#include <stdio.h>
int main()
{
      int n,l,f,sum;
      printf("Enter Two Digit Number: ");
      scanf("%d",&n);
      l=n%10;
      f=n/10;
      printf("\nFirst Digit = %d \nLast Digit  = %d\n",f,l);
      sum=l+f;
      printf("\nSum Both Digit = %d",sum);
      return 0;
}


Output:

read sum two digit