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

how to find sum of digits in C?

21 Answers   CTS, Infosys,


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

0 Answers   Wilco,


Tell me with an example the self-referential structure?

0 Answers  


please give me some tips for the selection in TCS.

3 Answers   TCS,


Is register a keyword in c?

0 Answers  






Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given

0 Answers   XYZ,


Why is c called "mother" language?

0 Answers  


Why isn't any of this standardized in c? Any real program has to do some of these things.

0 Answers  


void main() { int a=1; printf("%d %d %d",a,++a,a++); } the output is supposed to be 1 2 2....but it is 3 3 1 this is due to calling conventions of C. if anyone can explain me how it happens?

7 Answers  


int i=10; printf("%d %d %d", i, i=20, i);

0 Answers  


Write a c program to demonstrate Type casting in c?

2 Answers  


Is it possible to have a function as a parameter in another function?

0 Answers  


Categories