Miti059

3.find sum of first and last digit of a number

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