Online Compiler C

#include <stdio.h> int main() { int n,rev=0; scanf("%d",&n); while(n>0){ rev=rev*10+n/10; } printf("%d",rev); return 0; }
This code attempts to reverse the digits of an integer entered by the user, but it has a logical error in the loop. The variable `n` is never updated inside the loop, so the condition `n>0` remains true forever, causing an infinite loop. Also, the expression `n/10` is used incorrectly; it should extract the last digit, not the quotient.

- Inside the while loop, you need to update `n` by removing its last digit each iteration, for example by dividing by 10. Currently `n` never changes.
- To get the last digit of `n`, use the remainder operator `%` (like `n % 10`), not division. The expression `n/10` gives the number without the last digit, which is what you assign back to `n`.