Example C program to reverse given number:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include <stdio.h> int main() { int n, rev = 0; printf("Please enter a number to reverse\n"); scanf(""%d"",&n); while (n != 0) { rev = rev * 10; rev = rev + n%10; n = n/10; } printf("The reverse of entered number is %d\n", rev); return 0; } |