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
Explain the use of fflush() function?
Is malloc memset faster than calloc?
How can I write a function that takes a format string and a variable number of arguments?
I have a varargs function which accepts a float parameter?
What is the use of getchar() function?
Should I learn data structures in c or python?
Can a program have two main functions?
What does do in c?
What is difference between Structure and Unions?
write a program to print largest number of each row of a 2D array
Define Spanning-Tree Protocol (STP)
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
In C programming, what command or code can be used to determine if a number of odd or even?
What is use of pointer?
What is the process to generate random numbers in c programming language?