Saturday, March 3, 2012

PROGRAM TO FIND REVERSE OF ANY STRING


/*******************(soeasyprograms.blogspot.in)*************************/
/*A program to reverse any string*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[20];
int n,i;
clrscr();
printf("Enter any string\n");
gets(str);//to get any string
n=strlen(str);//to get the length of string
printf("The reverse of string is=\n");
for(i=n-1;i>=0;i--)
printf("%c",str[i]);//To print the elements of strin in reverse order
getch();
return 0;
}

/*******************(soeasyprograms.blogspot.in)*************************/

No comments:

Post a Comment