How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / vishnu
Try this ...
#include <stdio.h>
#include <stdlib.h>
int Rev (char *s, char *b)
{
int i ;
char c ;
if (*s == '\0')
{
return 0 ;
}
c = *s ;
i = Rev (s + 1, b) ;
b[i] = c ;
return i+1 ;
}
int main ()
{
int end ;
char str[] = "Billie jean is not my lover - MJ" ;
end = Rev (str, str) ;
str[end] = '\0' ;
printf ("Now [%s]\n", str) ;
exit (0) ;
}
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
Tell me what is null pointer in c?
What is actual argument?
Do you know the purpose of 'register' keyword?
What is call by value in c?
What is function and its example?
How variables are declared in c?
about c language
what is the diffrenet bettwen HTTP and internet protocol
The statement, int(*x[]) () what does in indicate?
Write a C program linear.c that creates a sequence of
processes with a given length. By
sequence it is meant that each created process has exactly
one child.
Let's look at some example outputs for the program.
Here the entire process sequence consists of process 18181:
Sara@dell:~/OSSS$ ./linear 1
Creating process sequence of length 1.
18181 begins the sequence.
An example for a sequence of length three:
Sara@dell:~/OSSS$ ./linear 3
Creating process sequence of length 3.
18233 begins the sequence.
18234 is child of 18233
18235 is child of 18234
........ this is coad .... BUt i could not compleate it .....:(
#include
Why is extern used in c?
What is wrong in this statement? scanf(ā%dā,whatnumber);
Explain what is the difference between #include and #include 'file' ?
How do you convert strings to numbers in C?
Can we change the value of constant variable in c?