Saturday, May 21, 2011

C program to reverse digits of number using function


Simple C Program reverse digits of number using function

int reversedigit(int);

int main()
{
int a;
printf("Enter a number :");
scanf("%d",&a);
int b=reversedigit(a);
printf("\nreverse= %d",b);
getch();
}
reversedigit(int x)
{
int y=0;
while(x)
{
y=y*10+x%10;
x=x/10;
}
return y;
}

No comments:

Post a Comment