C Program To Find The Reverse Of a Given Number
/** To Find Reverse Of a Number **/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include<stdio.h> //#include<conio.h> void main() { int num,rem,sum=0,rev; //clrscr(); printf("\n /** To Find Reverse Of a Number **/ \n"); printf("\n Enter a number: "); scanf("%d",&num); while(num) { rem=num%10; //for getting remainder by dividing with 10 num=num/10; //for getting quotient by dividing with 10 sum=sum*10+rem; } rev=sum; printf("\n The Reversed Number is: %d \n\n",rev); //getch(); return 0; } |
Output: ( using GNU GCC Compiler with code::blocks IDE, hence no need of clrscr(); and getch(); )