How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / mahesh auti
#include <stdio.h>
#include <conio.h>
#include <string.h>
int main(void)
{
char str1[] = "Mahesh";
char str2[80], *p1, *p2;
clrscr();
p1 = str1 + strlen(str1) - 1;
p2 = str2;
while(p1 >= str1)
*p2++ = *p1--;
*p2 = '\0';
printf("%s %s", str1, str2);
getch();
return 0;
}
| Is This Answer Correct ? | 26 Yes | 25 No |
Post New Answer View All Answers
Explain high-order bytes.
explain what is an endless loop?
find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }
How can I change their mode to binary?
What is a MAC Address?
write a proram to reverse the string using switch case?
What are the loops in c?
What is nested structure?
What is the purpose of main() function?
Explain what are header files and explain what are its uses in c programming?
Explain why c is faster than c++?
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??
Write a program to reverse a given number in c?
Do you have any idea how to compare array with pointer in c?
What is this pointer in c plus plus?