Write a program in C to reverse a number by recursive
function?
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>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 View All Answers
What is the function of volatile in c language?
What is volatile c?
Is it possible to pass an entire structure to functions?
What are c preprocessors?
Explain function?
What is the difference between NULL and NUL?
What is the meaning of 2d in c?
Why do we write return 0 in c?
What are the difference between a free-standing and a hosted environment?
What is variables in c?
What is c token?
Why is event driven programming or procedural programming, better within specific scenario?
What is dynamic memory allocation?
What is volatile, register definition in C
1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures