Prerequisite:
Reverse number:
Program
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 |
#include<stdio.h> int main() { unsigned long int numb,numb_temp,revrseNum=0; unsigned long int r; printf("\n Program to find reverse number"); printf("\nPlease enter any Number: "); scanf("%ld",&numb); numb_temp=numb; while(numb_temp>0) /*132 = 2 ----> 2*10+3=23------>23*10+1=231*/ { r=numb_temp%10; revrseNum=(revrseNum*10)+r; numb_temp=numb_temp/10; } printf("\nreverse of %ld is= %ld",numb,revrseNum); return 0; } |
1 2 3 4 5 |
Output: Program to find reverse number Please enter any Number:123 reverse of 123 is= 321 |