RE: .Write a function to reverse a string without using concatenation (Hint : Use array operations push pop)
In case you have stored a string
Ex: RAHUL
This is called string variable. Here RAHUL is stored as 012345 and at the end of the string a Null character will be added. The compiler will automatically add the null character.
R 0
A 1
H 2
U 3
L 4
NULL 5
What is the algorithm to reverse a string?
We need to know the length of the string. To find the length of the string we use
str len ();
This functions find the length, which can be stored in a variable.
Var = str len ();
for (i = var-1; i>=0; i–)
{
print f (“%c”, str[i])
==========================================
Follow the below program to Write a function to reverse a string without using concatenation
# include < stdio.h>
# include <conio.h>
# include <string.h>
main()
{
Char str(10);
int len;
printf(“enter a string”);
scanf(“%s”, str);
len=strlen (str);
for (i=len-1; i>=0; i–)
{
printf(“%c”, str[i];
}
getch();
}