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
Why clrscr is used in c?
What is c language and why we use it?
What is string constants?
Explain what is the benefit of using an enum rather than a #define constant?
Can we access the array using a pointer in c language?
What is the use of getchar() function?
Is null a keyword in c?
What does the format %10.2 mean when included in a printf statement?
What do you understand by friend-functions? How are they used?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
What is the use of pragma in embedded c?
What is hashing in c?
Explain a file operation in C with an example.
Explain union.
What is the correct code to have following output in c using nested for loop?