How to reverse a string using a recursive function, with
swapping?
Answer Posted / vignesh1988i
the corrected code is:::
#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!=count)
{
temp=a1[i];
a1[i]=a1[count1-1];
a1[count1-1]=temp;
i++;
reverse(--count1);
}
else
printf("\nthe reversed string is :%s",a1);
}
Is This Answer Correct ? | 1 Yes | 3 No |
Post New Answer View All Answers
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
I need testPalindrome and removeSpace
#include
Explain how can I read and write comma-delimited text?
What is NULL pointer?
What is the equivalent code of the following statement in WHILE LOOP format?
Why can’t constant values be used to define an array’s initial size?
What is a method in c?
What is the use of ?
What is spaghetti programming?
What are reserved words?
What is "Duff's Device"?
Is fortran faster than c?
Where we use clrscr in c?
Is c dynamically typed?
what is bit rate & baud rate? plz give wave forms