C PROGRAMMING

write a c program to reverse a given number

#include <stdio.h>
int main() {
int n, rev = 0, remainder;
printf("Enter an integer: ");
scanf("%d", &n);
while (n != 0) {
remainder = n % 10;
rev = rev * 10 + remainder;
n /= 10;
}
printf("Reversed number = %d", rev);
return 0;

getch();
}
Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button