Blog Moved

This website completely moved to new domain. For latest content, visit www.programmingposts.com

Search This Blog

9 Aug 2012

C Program To Find The Reverse Of a Given Number

/** To Find Reverse Of a Number **/
 
#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(); )



No comments:

Post a Comment