Saturday, July 27, 2019

Revers String without strrev() function

Revers String without strrev() function:


Revers String without strrev() function


#include<stdio.h>
#include<conio.h>

void main()
{
int i,j,k;
char str[100];
char rev[100];
clrscr();

printf("Enter A String:-");
gets(str);

for(i=0;str[i]!='\0';i++)
{

}

       // printf("The Original String is%d\n",i);

   k = i;
for(j=0;j<=k;j++ , i--)
{
rev[j]=str[i];
printf("%c" , str[i]);
}

printf("The Revers String is %s\n",rev);
getch();
}

Output:






EmoticonEmoticon