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
What is the data segment that is followed by c?
can we have joblib in a proc ?
What is an example of structure?
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
What is header file in c?
What is adt in c programming?
#include
What is the use of getch ()?
Is malloc memset faster than calloc?
what is the difference between 123 and 0123 in c?
What will the preprocessor do for a program?
Write a program of advanced Fibonacci series.
What is the use of #include in c?
Explain threaded binary trees?
What is pointer to pointer in c with example?