C Coding Questions With Solutions


Question :

Write a C-program to Check Whether a String is Palindrome or Not

  

   int main(int argc,char *argv[])
{
   int i,j,l,flag=1;
    if(argc!=2)
     exit(1);
    for(l=0;argv[1][l]!='\0';l++);
    j=l-1;
    for(i=0;i<=l/2;i++)
    {
        if(argv[1][i]!=argv[1][j])
          {
            flag=0;
          }
        j--;
    }
    if(flag==1)
        printf("Palindrome");
    else
        printf("Not Palindrome");
    return 0;
}