Write a program in C to reverse a number by recursive
function?



Write a program in C to reverse a number by recursive function?..

Answer / 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>10)//456
{
a=a/10;//a=45
b=b*10+a%10;//65
return rev(a,b);
}
else
return b;
}

Is This Answer Correct ?    17 Yes 7 No

Post New Answer

More C Interview Questions

What is a function simple definition?

0 Answers  


Where we use clrscr in c?

0 Answers  


Define function ?Explain about arguments?

2 Answers   Geometric Software, Infosys,


‎How to define structures? · ‎

0 Answers  


DIFFERNCE BETWEEN THE C++ AND C LANGUAGE?

2 Answers   Wipro,






Explain the bubble sort algorithm.

0 Answers  


Write a program to give following output..... ********* **** **** *** *** ** ** * * ** ** *** *** **** **** *********

4 Answers  


If you know then define #pragma?

0 Answers  


Explain what is a 'locale'?

0 Answers  


What happens if a header file is included twice?

0 Answers  


When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

0 Answers  


What is the difference between near, far and huge pointers?

0 Answers  


Categories