Pages

Wednesday, 3 October 2012

Reverse Number


#include <stdio.h>
#include <conio.h>

main()
{
                int n, rev, temp;
                clrscr();
               
                printf("Enter number to reverse : ");
                scanf("%d",&n);
               
                rev = 0;
               
                temp = n;
                while(temp!=0)
                {
                                rev = rev * 10;
                                rev = rev + temp%10;
                                temp = temp / 10;
                }
               
                printf("\n\nThe reverse of %d is %d",n,rev);
               
                getch();
                return 0;
}

0 comments:

Post a Comment