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...

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

Answer Posted / prakash

#include <stdio.h>

void reverse(char *str)
{
if (*str == '\0')
return;

reverse(str+1);

printf("%c", *str);
}

int main()
{
char str[50];

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

printf("Reversed string: ");
reverse(str);
printf("\n");

return 1;
}

Is This Answer Correct ?    23 Yes 24 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is c language in simple words?

1023


How can I do peek and poke in c?

1043


Explain how do you convert strings to numbers in c?

1031


What are the differences between Structures and Arrays?

1146


What is c value paradox explain?

1033


Define the scope of static variables.

1073


When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

1011


How do I copy files?

1009


Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?

968


What is keyword in c?

971


what will be the output for the following main() { printf("hi" "hello"); }

10844


In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

2071


How can I remove the leading spaces from a string?

1104


How can I find out the size of a file, prior to reading it in?

1110


Write a program to use switch statement.

1088