to find out the reverse digit of a given number

Answer Posted / sreejesh1987

int rev(int,int);
void main()
{
int a,b;
clrscr();
printf("\nEnter the number to reverse:");//456
scanf("%d",&a);
b=a%10;//b=6
printf("\nReverse of the number is: %d",rev(a,b));
getch();
}

int rev(int a,int b)
{
if(a>9)//456
{
a=a/10;//a=45
b=b*10+a%10;//65
return rev(a,b);
}
else
return b;
}

Is This Answer Correct ?    3 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what do you mean by inline function in C?

618


Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.

3691


List the difference between a "copy constructor" and a "assignment operator"?

583


Why does everyone say not to use gets?

610


How can I read and write comma-delimited text?

621






What are local static variables?

619


What is an auto keyword in c?

642


What does printf does?

747


#include { printf("Hello"); } how compile time affects when we add additional header file .

1424


How can I write functions that take a variable number of arguments?

626


Define and explain about ! Operator?

615


Can we declare variables anywhere in c?

580


Can you mix old-style and new-style function syntax?

664


How can I swap two values without using a temporary?

618


Is fortran faster than c?

582