Sunday, 13 January 2013

Program to print the length and reverse of string in C

#include
#include
#include
void main()
{
            char str[20],str1[20],ch;
            int len,i,j;
            clrscr();
            printf("\n Enter the String:-");
            gets(str);
            for(len=0;str[len]!='\0';len++);
            j=0;
            for(i=len-1;i>=0;i--)
            {
            str1[j]=str[i];
            j++;
            }
            str1[j]='\0';
            printf("\nLength=%d\nReverse of String=%s",len,str1);

getch();
}                                 

Output




Enter your email address:

Delivered by FeedBurner