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

Answer Posted / vinay tiwari

void reverse(char *,int b);
void main()
{
char a[26];
int len;
clrscr();
printf("enter string ");
gets(a);
len=strlen(a);
reverse(a,len);
getch();
}
void reverse(char * a,int len)
{
if(len==0)
printf("%c",a[len]);
else
{
printf("%c",a[len]);
reverse(a,len-1);
}
}

Is This Answer Correct ?    177 Yes 62 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are register variables in c?

575


What are the 5 types of organizational structures?

550


The __________ attribute is used to announce variables based on definitions of columns in a table?

671


Is a house a shell structure?

697


Why void is used in c?

566






‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .

2372


Explain main function in c?

626


Create a simple code fragment that will swap the values of two variables num1 and num2.

813


Explain enumerated types in c language?

606


Give me the code of in-order recursive and non-recursive.

886


how to construct a simulator keeping the logical boolean gates in c

1729


Is it cc or c in a letter?

566


find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }

1857


Explain how can a program be made to print the line number where an error occurs?

694


Which type of language is c?

653