write a program to check given string is palindrome or not in C

 //write a program to check given string is palindrome or not

#include <stdio.h>

#include <string.h>

int main()

{

char string[20];

int i, length, temp=0;

int flag=0;


printf("Enter a string: ");

scanf("%s", string);


length=strlen(string);


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

{

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

temp = 1;

break;

}

}

if (temp==0) {

printf("string is a palindrome");

}

else{

printf("string is not a palindrome");

}

return 0;

}

Comments

Popular posts from this blog

Automations and robotics

Palindrome Pattern Program In Java Language

Rhombus Pattern Program In Java Language