How to reverse a string using a recursive function, with
swapping?
Answer Posted / vignesh1988i
#include<stdio.h>
#include<conio.h>
char a1[50]; //GLOABAL VAR.
void reverse(int);
void main()
{
int count=0;
printf("enter the string :");
scanf("%s",a1);
for(int i=0;a1[i]!='\0';i++)
count++;
reverse(count);
getch();
}
void reverse(int count1)
{
char temp;
static int i=0;
if(i<=count1/2)
{
temp=a1[i];
a1[i]=a1[count1-1];
a1[count1-1]=temp;
i++;
reverse(--count1);
}
else
printf("\nthe reversed string is :%s",a1);
}
thank u
Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
Write a program to print fibonacci series using recursion?
a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
What is array of pointers to string?
How reliable are floating-point comparisons?
What is a static variable in c?
Why we use conio h in c?
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above
Explain what is dynamic data structure?
What are the types of type specifiers?
What is the importance of c in your views?
A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?
If you know then define #pragma?
p*=(++q)++*--p when p=q=1 while(q<=6)