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
How to find a missed value, if you want to store 100 values in a 99 sized array?
What is the difference between functions abs() and fabs()?
#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }
Is there any possibility to create customized header file with c programming language?
What is the difference between pure virtual function and virtual function?
What is structure and union in c?
How can I pad a string to a known length?
What is struct node in c?
Is it better to use malloc() or calloc()?
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
Why array is used in c?
What is a pointer in c plus plus?
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above
Does c have an equivalent to pascals with statement?
What is the scope of an external variable in c?