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

Answer Posted / sravani

#include<stdio.h>
void strrev(char *);
main()
{
char s1[10];
printf("enter the string:");
scanf("%s",s1);
strrev(s1);
}
void strrev(char *p)
{
int i,j;
i=0,j=strlen(p)-1;
char temp;
while(i<j)
{
temp=p[i];
p[i]=p[j];
p[j]=temp;
i++;
j--;
strrev(s1);
}

Is This Answer Correct ?    5 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages and disadvantages of c language?

550


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

2573


Tell me with an example the self-referential structure?

558


What is a memory leak? How to avoid it?

557


a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor

627






can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......

1396


Can we declare variables anywhere in c?

563


What are different types of variables in c?

559


Explain what is the benefit of using const for declaring constants?

602


Explain what is wrong with this program statement? Void = 10;

754


Without Computer networks, Computers will be half the use. Comment.

1861


Write a Program to find whether the given number or string is palindrome.

603


What is the difference between declaring a variable by constant keyword and #define ing that variable?

2681


What is a macro, and explain how do you use it?

615


Explain c preprocessor?

671