Advertisement
RIFATKHAN1

sum of first and last digit of a number.

Jun 23rd, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.26 KB | None | 0 0
  1. #include<stdio.h>
  2. int  main()
  3.  
  4. {
  5.     int num,fd,ld,sum=0;
  6.     scanf("%d",&num);
  7.     ld=num%10;
  8.  
  9.     while(num>=10)
  10.  
  11.     {
  12.         num = num/10;
  13.     }
  14.  
  15.     fd=num;
  16.     sum=fd+ld;
  17.  
  18.     printf("first and last digit sum = %d\n",sum);
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement