How to reverse a string using a recursive function, with
swapping?
Answer Posted / vignesh1988i
my next logic:::
#include<stdio.h>
#include<conio.h>
void reverse(char*,char*);
void main()
{
char a1[50],*p;
int count=0;
printf("enter the string:");
scanf("%s",a1);
for(int i=0;a[i]!='\0';i++)
count++;
p=a1+(count-1);
reverse(a1,p);
printf("the reversed one is : %s",a1);
getch();
}
void reverse(char *a1,char *p)
{
char temp;
if(a1<=p)
{
temp=*a1;
*a1=*p;
*p=temp;
reverse(++a1,--p);
}
}
thank u
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Why is not a pointer null after calling free?
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
Can a variable be both const and volatile?
What is a pointer and how it is initialized?
Is main is user defined function?
What is modifier & how many types of modifiers available in c?
I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.
I came across some code that puts a (void) cast before each call to printf. Why?
How do you do dynamic memory allocation in C applications?
Do you know the difference between malloc() and calloc() function?
Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record
Compare interpreters and compilers.
If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..
What is pointer in c?