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 can you return multiple values from a function?

0 Answers  


HOW TO FIND OUT THE RREVERS OF A GIVEN DIGIT NUMBER IF IT IS INPUT THROUGH THE KEYBORD BY USING C LANGUAGE

3 Answers   Wipro,


What is pivot in c?

0 Answers  


find out largest elemant of diagonalmatrix

0 Answers  


Why cann't whole array can be passed to function as value.

1 Answers  






What are disadvantages of C language.

0 Answers   iNautix,


Give basis knowledge of web designing ...

0 Answers   HCL,


Why #include is used in c language?

0 Answers  


If input is 123 then how to print 100 and 20 and 3 seperately?

4 Answers  


Explain 'bit masking'?

0 Answers   EXL,


main() { FILE *fs; char c[10]; fs = fopen(“source.txt”, ”r”); /* source.txt exists and contains “Vector Institute” */ fseek(fs,0,SEEK_END); fseek(fs,-3L,SEEK_CUR); fgets(c,5,fs); puts(c); }

1 Answers   Vector,


#include<std.h> int main() { char *str[]={"Frogs","Do","Not","Die","They","Croak!"}; printf("%d %d\n",sizeof(str),strlen(str)); ...return 0; } what will the output of the above program?

6 Answers  


Categories