SAADQUAMER

sum of first and last digit

Jun 21st, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. //Write a C program to find sum of first and last digit of a number.
  2. #include<stdio.h>
  3. int main(){
  4.  
  5. int x,FN,LN;
  6. printf("Enter a Number :");
  7. scanf("%d",&x);
  8. LN=x%10;
  9. while(x>10){
  10.     x=x/10;
  11.     FN=x;
  12. }
  13.  
  14. printf("Sum of First and last Digit Is :%d\n",FN+LN);
  15. return 0;
  16.  
  17.  
  18.  
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment