Advertisement
afrinahoque

Sum of first and last digit of a number.

Jun 22nd, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.25 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int n, fd, ld, sum=0;
  5.     printf("Enter the number:");
  6.     scanf("%d", &n);
  7.     ld=n%10;
  8.     while (n>=10)
  9.     {
  10.         n=n/10;
  11.     }
  12.     fd=n;
  13.     sum=fd+ld;
  14.     printf("sum=%d", sum);
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement