write a C code
to reverse a string using a recursive function, without
swapping or using an extra memory.

Answer Posted / jainendra

#include<stdio.h>
#define MAX 100
char* getReverse(char[]);

int main(){

char str[MAX],*rev;

printf("Enter any string: ");
scanf("%s",str);

rev = getReverse(str);

printf("Reversed string is: %s",rev);
return 0;
}

char* getReverse(char str[]){

static int i=0;
static char rev[MAX];

if(*str){
getReverse(str+1);
rev[i++] = *str;
}

return rev;
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the data segment that is followed by c?

619


can we have joblib in a proc ?

1661


What is an example of structure?

593


Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings

2253


What is header file in c?

609






What is adt in c programming?

621


#include #include struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

5222


What is the use of getch ()?

644


Is malloc memset faster than calloc?

625


what is the difference between 123 and 0123 in c?

729


What will the preprocessor do for a program?

596


Write a program of advanced Fibonacci series.

715


What is the use of #include in c?

587


Explain threaded binary trees?

684


What is pointer to pointer in c with example?

556