fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int n;
  5. printf("Enter the number: ");
  6. scanf("%d",&n);
  7. int r=0;
  8. int lastdigit=0;
  9. while(n!=0){
  10. lastdigit= n%10;
  11. r=r*10;
  12. r= r + lastdigit;
  13. n=n/10;
  14. }
  15. int sum;
  16. sum=n+r;
  17. printf("The sum is %d",sum);
  18.  
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 5288KB
stdin
12
stdout
Enter the number: The sum is 21