C Program to Check Whether a Strings is Palindrome or not ?

In this C program, We will see “How to check Whether a Strings is Palindrome or not ?” . So, let’s do it …

#include<stdio.h>
int main()
{
    char A[] = "programming";
    char B[30];

    strlen(A);
    printf("Length of A = %d\n",strlen(A));

    int d = strlen(A);
    int i=d-1, j=0;

    while(i>=0,j<d)
          {
              B[j] = A[i];
              i--;
              j++;

          }

    printf("String1 = %s\n",A);
    printf("String2 = %s\n\n",B);

    //logic for palindrome part.
    int c = strcmp(A,B);
    if(c==0)
    {
        printf("Strings are Palindrome");
    }
    else
        printf("Strings are not Palindrome.");

    getch();

    return 0;
}

Keep Learning with PrologiCode.

Leave a Comment