fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.  
  5. int n, reverse = 0, remainder;
  6.  
  7. printf("Enter an integer: ");
  8. scanf("%d", &n);
  9.  
  10. while (n != 0) {
  11. remainder = n % 10;
  12. reverse = reverse * 10 + remainder;
  13. n /= 10;
  14. }
  15.  
  16. printf("Reversed number = %d", reverse);
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 5304KB
stdin
145
stdout
Enter an integer: Reversed number = 541