How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / prakash
#include <stdio.h>
void reverse(char *str)
{
if (*str == '\0')
return;
reverse(str+1);
printf("%c", *str);
}
int main()
{
char str[50];
printf("Enter the string: ");
scanf("%s", str);
printf("Reversed string: ");
reverse(str);
printf("\n");
return 1;
}
Is This Answer Correct ? | 23 Yes | 24 No |
Post New Answer View All Answers
What is a #include preprocessor?
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
Place the #include statement must be written in the program?
What functions are in conio h?
If jack lies on Mon, Tue Wed and jill lies on Thursday, Friday and Saturday. If both together tell they lied yesterday. So c the given options and then c cos in the given dates one will be saying the truth and one will be lying. I got Thursday as option because jack is saying the truth he lied yest but jill is lying again as he lies on that day.
Explain the use of bit fieild.
Why we write conio h in c?
Does c have an equivalent to pascals with statement?
How can I make it pause before closing the program output window?
How does sizeof know array size?
How can I do serial ("comm") port I/O?
what is reason of your company position's in india no. 1.
What is c standard library?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.