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. printf("The reverse of the number is %d",r);
  16. int sum;
  17. sum=n+r;
  18. printf("The sum is %d",sum);
  19.  
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5288KB
stdin
12
stdout
Enter the number: The reverse of the number is 21The sum is 21