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 / asif

#include <stdio.h>
#include <string.h>

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

reverse(str+1);

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

int main()
{
char str[50];
char *ptr;
printf("Enter the string: ");
//scanf("%s", str);
fgets(str,50,stdin);
ptr = strchr(str,'\n');
*ptr = '\0';

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

return 1;
}

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is clrscr ()?

1111


What is else if ladder?

1025


Simplify the program segment if X = B then C ← true else C ← false

3021


Write a program in c to replace any vowel in a string with z?

1132


What are the advantages and disadvantages of c language?

1019


What is signed and unsigned?

1067


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

2076


What is meant by errors and debugging?

1112


C language questions for civil engineering

1722


What is static function in c?

1121


Which is better malloc or calloc?

1105


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

1069


Is there any demerits of using pointer?

1075


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

2346


program to convert a integer to string in c language'

2458