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

#include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); } what is the output for this?

4 Answers   IIIT,


What is a macro?

0 Answers  


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

0 Answers   CSC, Wipro,


What is define c?

0 Answers  


What is an volatile variable?

15 Answers   HP,


What is the difference between i++ and i+1 ?(in terms of memory)

3 Answers   HCL,


What is dynamic variable in c?

0 Answers  


What is wrong in this statement?

0 Answers  


What is the restrict keyword in C?

2 Answers  


main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none

0 Answers  


could u able to tell about suresoft technical session

1 Answers  


a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f

0 Answers   TCS,


Categories