Skip to main content

Reverse a given number

#include <stdio.h> #include <math.h> int main() { int n, n2 = 0 , rem; printf("Enter a number : "); scanf("%d" , &n ); while( n > 0 ) { rem = n % 10; n2 = n2 * 10 + rem; n = n / 10; } printf("\n\nThe reversed number is : %d\n\n", n2); }






Comments