C Program to Sum of The First and Last Digit Of 'n' Digit Number

How to write a C Program to Sum of The First and Last Digit Of  'n' Digit Number  in C Programming Language ?


  1. int main()
  2. {
  3. int num,len,last;
  4. printf("\nEnter n digit number \n");
  5. scanf("%d",&num);
  6. last=num%10;
  7. while(num>0)
  8. {
  9. num=num/10;
  10. len=len+1;
  11. }
  12. num=num/(pow(10,len-1));
  13. num=num%10;
  14. printf("the result is %d",last+num);
  15. getch();
  16. return 0;
  17.  
  18. }


Learn More :