Tuesday, July 26, 2011

Checking whether a String is Palindrome,Complete Source Code

Strings which are read the same, both forward and backward  are called Palindrome Strings eg:malayalam. Palindrome checking is a Common Program for Beginners.The program below can be used to check whether a String is a Palindrome.

 #include<stdio.h>  
 #include<conio.h>  
 #include<string.h>  
 void main()  
 {  
 int i,l,f=0;  
 char a[20];  
 printf("\nEnter the string:");  
 scanf("%s",a);  
 l=strlen(a);  
 for(i=0,l=l-1;a[i]!='\0';i++,l--)  
 {  
 if(a[i]!=a[l])  
 {  
 f=1;  
 break;  
 }  
 }  
 if(f==0)  
 printf("String is palindrome");  
 else  
 printf("String is not palindrome");  
 }  

No comments:

Post a Comment

Which is the Best Photo Watermarking Software

Photo Theft is becoming more and more common in the web with the outburst of social websites like Facebook,Google Plus and Image sharing se...