How to reverse a string using a recursive function, without
swapping or using an extra memory?

Answer Posted / vinay tiwari

void reverse(char *,int b);
void main()
{
char a[26];
int len;
clrscr();
printf("enter string ");
gets(a);
len=strlen(a);
reverse(a,len);
getch();
}
void reverse(char * a,int len)
{
if(len==0)
printf("%c",a[len]);
else
{
printf("%c",a[len]);
reverse(a,len-1);
}
}

Is This Answer Correct ?    177 Yes 62 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.

1757


why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above

646


Explain how do you determine whether to use a stream function or a low-level function?

616


What is the most efficient way to store flag values?

676


What is the translation phases used in c language?

622






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

1577


How is pointer initialized in c?

575


What is variable and explain rules to declare variable in c?

545


Should I learn data structures in c or python?

569


What is the difference between far and near ?

674


How can I make it pause before closing the program output window?

565


Do pointers take up memory?

645


Which one would you prefer - a macro or a function?

590


Where is volatile variable stored?

637


write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);

1832