Tuesday, January 24, 2012

Sample C Program To Accept A String & Display In Reverse.

#include
#include
#include


char reverse(char *p);

void main()
{

int i;
char str[10];
clrscr();
printf(" \n \n Enter the String: \t ");
gets(str);
reverse(str);
getch();

}

char reverse(char *p)
{

int j,l;
l = strlen(p);
printf(" \n \n String in reverse is: \t ");
for(j = l - 1; j >= 0; j--)
{
printf("%c",p[j]);
}
return 1;

}

No comments:

Post a Comment