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

hi folks i m approching for h1 b interview on monday 8th of august at montreal and i m having little problem in my approval notice abt my bithdate my employer has made a mistake while applying it is 12th january and istead of that he had done 18 the of january do any body have any solution for that if yes how can i prove my visa officer abt my real birthdate it urgent please let me know guys thaks dipesh patel

1406


What does *p++ do?

580


Why structure is used in c?

584


Explain what is gets() function?

623


How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

583






What does 3 periods mean in texting?

595


How can I find the modification date and time of a file?

596


When can you use a pointer with a function?

563


application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above

599


Write a program with dynamically allocation of variable.

600


Explain how can I open a file so that other programs can update it at the same time?

586


Why is python slower than c?

598


a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above

650


Explain modulus operator. What are the restrictions of a modulus operator?

595


What is a keyword?

740