Saturday, August 21, 2010

Article | C program To Check Whether given String is a Pallindrom Or Not

C program To Check Whether given String is a Pallindrom Or Not

  • Without Using Any String Functions




    1. #include <stdio.h>

    2. #include<conio.h>

    3. void main()

    4. {

    5. char str[50];

    6. int len=0,i=0,j,flag=1;

    7. clrscr();

    8. printf("Enter a string: ");

    9. gets(str);

    10. while(str[i++]!='\0')

    11. len++;

    12. for(i=0,j=(len-1);i<len/2;i++,j--)

    13. {

    14. if(str[j]!=str[i])

    15. {

    16. flag=0;

    17. break;

    18. }

    19. }

    20. if(flag==1)

    21. printf("String is a palindrome");

    22. else

    23. printf("String is not a palindrome");

    24. getch();

    25. }

    Loading...

    Comments :

    0 comments to “ C program To Check Whether given String is a Pallindrom Or Not ”

    Top Views

    BloggerTipsTemplates

    CHICKLETS

    Enter your email address:

    Delivered by FeedBurner

    Followers