C program to reverse a string

Code:
#include<stdio.h>
void main()
{
char str[100],rstr[100];
int i,j,lenstr,k;
printf("\nEnter a string \t:");
scanf("%s",str);
for(i=0;str[i]!='\0' ;i++);
lenstr=i;
for(j=lenstr-1,k=0;j!=-1;j--,k++)
{
rstr[k]=str[j];
}
rstr[k]='\0';
printf("\n%s",rstr);
}
view raw Stringreverse.c hosted with ❤ by GitHub

Comments

Popular posts from this blog

C++ programming toll plaza simulation program