Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 scope and lifetime of a variable in c?

989


Which programming language is best for getting job 2020?

985


What is sizeof array?

1002


Can math operations be performed on a void pointer?

970


Write a program to print factorial of given number without using recursion?

951


Describe dynamic data structure in c programming language?

1039


how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.

1626


Which is the best website to learn c programming?

1032


What does char * * argv mean in c?

999


What are enumerated types?

1104


What is this infamous null pointer, anyway?

988


Explain what is page thrashing?

1053


Is swift based on c?

1053


An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

1104


What are qualifiers and modifiers c?

940