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
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
What are the types of i/o functions?
Write a c program to build a heap method using Pointer to function and pointer to structure ?
How many levels of pointers can you have?
Why c is a procedural language?
What is structure pointer in c?
What does %c do in c?
What is c preprocessor mean?
Differentiate abs() function from fabs() function.
can anyone suggest some site name..where i can get some good data structure puzzles???
Why does not c have an exponentiation operator?
What are categories used for in c?
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;