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

program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

0 Answers  


List the difference between a While & Do While loops?

0 Answers   Accenture,


Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 5 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.

1 Answers  


What is the difference between text and binary i/o?

0 Answers  


c program to subtract between two numbers without using '-' sign and subtract function.

1 Answers  


main() { printf(5+"Vidyarthi Computers"); }

6 Answers  


application of static variables in real time

1 Answers   Bosch,


explain what is fifo?

0 Answers  


How do you do dynamic memory allocation in C applications?

0 Answers  


What is the difference between constant pointer and constant variable?

0 Answers   NIIT,


How can I ensure that integer arithmetic doesnt overflow?

0 Answers  


In CMM or CMMI certified organizations,we assess only the standard software processes of the organization. We do not assess the organizations other functional departments like HR or Admin. Then how can we certify the entire organization as CMM level company?? We have assessed only software related activities. Right. There is no relation with other departments like Accounts, HR or Admin. Then how can we claim that the whole company is a CMM certified company?

1 Answers   Melstar,


Categories