Reverse a string

Algorithm

Input   A string;  
Output  Reverse of string  
complexity  O(n).  
  
Reverse(s1)//reverses string s1  
1.  Initialize ctr := 0.  
2.  while(s1!=’\0’)  
3.  [increment ctr] ctr++,   
4.  Repeat for i=ctr to 0  
print : *(s1+i)  
5.  [end]  

Algorithm Description

Ctr :counter;
Ctr count the number of elements in the string.
For loop for print the string in the reverse order. 

C Code

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
	char str[100];
	int i,n,d;
	printf(" \n Enter the string :");
	gets(str);
	n=strlen(str);
	printf("Reverse of String is %s",strrev(str));
	return(0);        
}