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

Answer Posted / mahesh auti

#include <stdio.h>
#include <conio.h>
#include <string.h>
int main(void)
{

char str1[] = "Mahesh";
char str2[80], *p1, *p2;

clrscr();

p1 = str1 + strlen(str1) - 1;

p2 = str2;

while(p1 >= str1)
*p2++ = *p1--;

*p2 = '\0';

printf("%s %s", str1, str2);

getch();

return 0;
}

Is This Answer Correct ?    26 Yes 25 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

813


What is array of structure in c?

594


What is an expression?

656


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

2578


In which language linux is written?

604






How can you increase the size of a dynamically allocated array?

641


What are the characteristics of arrays in c?

616


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

1764


What are extern variables in c?

549


How do you list files in a directory?

563


Write a program to implement queue.

666


How can my program discover the complete pathname to the executable from which it was invoked?

660


How can you find the exact size of a data type in c?

601


What are the advantages of union?

628


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1450