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 do you print only part of a string?

602


What are the different data types in C?

716


I have a varargs function which accepts a float parameter?

564


How can I automatically locate a programs configuration files in the same directory as the executable?

614


On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area

643






c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above

602


What is the difference between text files and binary files?

663


can anyone suggest some site name..where i can get some good data structure puzzles???

1637


Explain the difference between structs and unions in c?

564


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

599


What is printf () in c?

570


What is structure in c definition?

562


why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above

627


What is queue in c?

563


What is array of structure in c?

584