Code In Tech - The Ultimate World of Computer Technology

Saturday, 24 March 2012

C Program to check whether the given string is Palindrome or not

SOURCE CODE:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
 char str1[20],str2[20];
 int i;
 clrscr();
 printf("\nEnter the string....");


scanf("%s",str1);
 strcpy(str2,str1);
 strrev(str2);
 i=strcmp(str1,str2);
  if(i==0)
   {
    printf("%s is PALINDROME",str1);
   }
  else
   {
    printf("%s is NOT PALINDROME",str1);
   }
 getch();
}

No comments :

Post a Comment