STRING PALINDROME


   TO CHECK GIVEN STRING IS PALINDROME OR NOT.






#include<stdio.h>
#include<conio.h>
void main()
   {
       char s1[10];int n1=0;
int i,flag;
  printf("Enter 1st string\n");
  scanf("%s",&s1);
   for(i=0;s1[i]!='\0';i++)
       n1++;
        n1=n1--;
   for(j=n1;j>=0;j--)
     {
flag=0;
  if(s1[i]==s1[j])
     flag=1;
  if(s1[i]!=s1[j])
    {
break;
    }
  if(i==j)
   {
break;
   }
       i++;
     }
if(flag==1)
   printf("String is palindrome\n");
       else
   printf("String is not palindrome\n");
   
   getch();
   }


No comments:

Post a Comment

If you have any problems related to solutions or any concept please let me know.

Copyright (c) 2020 Custom Programs All Right Reserved

Pages