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
What oops means?
What are pointers?
Is array name a pointer?
What are identifiers in c?
What is an identifier?
how can I convert a string to a number?
What is ## preprocessor operator in c?
How do you list a file’s date and time?
How are pointers declared in c?
What is an endless loop?
What does p mean in physics?
What are the keywords in c?
Explain what header files do I need in order to define the standard library functions I use?
Differentiate abs() function from fabs() function.
How does selection sort work in c?