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 + lastdigit;
  12. r=r*10;
  13. n=n/10;
  14. }
  15. printf("The reverse of the number is %d",r);
  16.  
  17.  
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0.01s 5320KB
stdin
45
stdout
Enter the number: The reverse of the number is 540