How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / aditi parab
#include <stdio.h>
int main ()
{
int i,j;
char a[10];
char temp;
//clrscr (); // only works on windows
gets(a);
for (i=0;a[i]!='\0';i++);
i--;
for (j=0;j <= i/2 ;j++)
{
temp = a[j];
a[j] = a[i-j];
a[i-j] = temp;
}
printf("%s",a);
return(0);
}
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }
What is the difference between #include and #include 'file' ?
What is nested structure?
What is getch() function?
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
What does 3 mean in texting?
Can true be a variable name in c?
Write a program to swap two numbers without using a temporary variable?
Is fortran still used today?
How pointers are declared?
Explain null pointer.
Explain what is the difference between a string and an array?
What is the deal on sprintf_s return value?
What are types of structure?
Explain what are global variables and explain how do you declare them?