Reverse of a given number
void main()
{
int num,out;
clrscr();
scanf("%d",&num);
out=rev(num);
printf("%d",out);
getch();
}
int rev(int num)
{
static sum,r;
if(num)
{
r=num%10;
sum=sum*10+r;
rev(num/10);
}
else return 0;
return sum;
}
void main()
{
int num,out;
clrscr();
scanf("%d",&num);
out=rev(num);
printf("%d",out);
getch();
}
int rev(int num)
{
static sum,r;
if(num)
{
r=num%10;
sum=sum*10+r;
rev(num/10);
}
else return 0;
return sum;
}
Posted by Naresh Kumar at 5:12 AM
Labels: reverse of a given number
0 comments:
Post a Comment