Monday, September 12, 2011

Reverse any given integer

/* to reverse any given integer */
#include<stdio.h>
#include<conio.h>
main()
{
    int n,m,x,sum=0;
    clrscr();
    printf("\ngive the number:");
    scanf("%d",&n);
    m=n;
    while(n>0)
    {
    x=n%10;
    sum=sum*10+x;
    n=n/10;}
    printf("\ngiven number is =%d",m);
    printf("\nreversed number is =%d",sum);
       getch();
       }

No comments:

Post a Comment

Popular 5 Posts Last 7 days