Reverse a string in C

#include<stdio.h>
void main()
{
	char name[20];
	int l=0,i;
	printf("\n Enter your name=>");
	gets(name);
	
	for(i=0;name[i]!=NULL;i++)
		l++;
		
	printf("\n Your name is %d length",l);
	printf("\n");
	for(i=l-1;i>=0;i--)
	{
		printf("%c",name[i]);
	}
}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *