Thursday, 11 September 2014

Check Palindrome String or Not

/*Check Palindrome String or Not*/

Solution:

#include<stdio.h>
#define SIZE 100
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
int main (){

 int range,i,j = 0,count = 0;
 char Palindrome[SIZE],temp[SIZE];
 printf("Enter word range : ");
 scanf("%d",&range);
 printf("Enter a word : ");
 for( i = 0; i < range;i++){
 
  scanf("%s",&Palindrome[i]);
 }
 for(i = range - 1; i >= 0;i--){
 
  temp[j++] = Palindrome[i];
 }
 for(i = 0; i < range; i++){
 
  if(Palindrome[i] == temp[i]){
  
   count++;
  }
 }
 if(count == range){
 
  printf("Palindrome String\n");
 }
 else{
 
  printf("Not a Palindrome string\n");
 }
 return 0;
}

No comments:

Post a Comment