C Programming Code Examples C > Mathematics Code Examples C Program to Reverse a Given Number C Program to Reverse a Given Number - Take the number which you have to reverse as the input. - Obtain its quotient and remainder. - Multiply the separate variable with 10 and add the obtained remainder to it. - Do step 2 again for the quotient and step 3 for the remainder obtained in step 4. - Repeat the process until quotient becomes zero. - When it becomes zero, print the output and exit. #include <stdio.h> void main() { long j, reverse = 0, temp, remainder; printf("Enter the number\n"); scanf("%ld", &j); temp = j; while (j > 0) { remainder = j % 10; reverse = reverse * 10 + remainder; j /= 10; } printf("Given number = %ld\n", temp); printf("Its reverse is = %ld\n", reverse); }