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

Answer Posted / cmp

#include <stdio.h>
void print(char *s,int size){
if(size<0)
printf(" ");
else

{
printf("%c",*(s+size-1));
print(s,size-1);
}
}

void main(){
char *s={"aliveli"};
int size=0,i=0;

while(*(s+i)!='\0'){
size++;
i++;
}
print(s,size);
}

Is This Answer Correct ?    6 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I make sure that my program is the only one accessing a file?

934


What is the equivalent code of the following statement in WHILE LOOP format?

1086


What are different storage class specifiers in c?

849


What is malloc calloc and realloc in c?

911


What are the parts of c program?

838


Differentiate between a for loop and a while loop? What are it uses?

915


What is difference between arrays and pointers?

764


 write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare.  You will then tabulate this information in another file.

1946


What is the difference between ++a and a++?

933


Differentiate between ordinary variable and pointer in c.

848


What is modeling?

815


Write a C program to count the number of email on text

1641


In c programming, explain how do you insert quote characters (? And ?) Into the output screen?

987


Explain what is a stream?

798


Explain how do you search data in a data file using random access method?

901