Palindrome string

Program:

#include<stdio.h>
#include<string.h>
int main()
{
char str[30];
int i,j,flag=0;
printf("Enter a string: ");
scanf("%s",str);
for(i=0,j=strlen(str)-1;i<strlen(str)/2;i++,j--)
{
   if(str[i]!=str[j])
   {
      flag=1;
  break;
   }
}
if(flag==0)
{
printf("Palindrome");
}
else
{
printf(" Not Palindrome");
}
return 0;
}

Output:




No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...