Palindrome

Description:

Teacher gave homework to the students that their task is to find a stirng which should remains the same even when we reverse it. Paul was interested in finding such string. Help paul by writing a code to find whether the given string is palindrome or not. Test Case 1 Input (stdin) mam Expected Output Palindrome Test Case 2 Input (stdin) Educate Expected Output Not palindrome

Program :


#include <stdio.h>

#include <string.h>

int main(){

    char string1[20];

    int i, length;

    int flag = 0;

    scanf("%s", string1);

   

    length = strlen(string1);

   

    for(i=0;i < length ;i++){

        if(string1[i] != string1[length-i-1]){

            flag = 1;

            break;

   }

}

   

    if (flag) {

        printf("Not palindrome");

    }  

    else {

        printf("Palindrome");

    }

    return 0;

}