Skip to main content

Program to find the given string is a Palindrome or not using C

/*Program to find the given string is a Palindrome or not */

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
   char a[15];
   int i, len, count=0;

   clrscr();
   printf("\nEnter a string: ");
   scanf("%s", a);

   len=strlen(a);

   for(i=0; i<len; i++)
   {
      if(a[i]==a[len-i-1])
      count=count+1;
   }

   if(count==len)
   {
     printf("\nThe given string is a Palindrome");
   }
   else
   {
     printf("\nThe  given string is not a Palindrome");
   }
   getch();
}


OUTPUT:

Enter a string:  hannah
The given string is a Palindrome


Enter a string:  welcome
The given string is not a Palindrome

Comments

Popular posts from this blog

Four Square pattern using Python program

Four Square Pattern import turtle turObj = turtle.Turtle() turObj.getscreen().bgcolor("#555555") turObj.speed(5000) def star(turtle, size):     if size <=5:         return     else:         for i in range(4):             turObj.color("#FFFFFF")             turtle.forward(size)             star(turtle,size/2)             turtle.left(270) star(turObj,100)        turtle.done() Output:

Star Design using Python program

Star Design import turtle turObj = turtle.Turtle() turObj.getscreen().bgcolor("#555555") turObj.speed(10) def star(turtle, size):     if size <=10:         return     else:         for i in range(30):             turObj.color("#FEACFF")             turObj.forward(i * 15)             turObj.right(144)            star(turObj,100)        turtle.done() Output: