Cheking whether a string palindrome
#include<stdio.h>#include<conio.h>#include<string.h>void main(){int n,i,flag=0,j;char a[32];clrscr();printf("enter the string");scanf("%s",a);n=strlen(a);for(i=0,j=n-1;(i<n)&&(j>0);j--,i++){if(a[i]!=a[j])flag=1;}if(flag==1)printf("the string is not palindrom");elseprintf("the string is palindrome");getch();}
0 Comments:
Post a Comment