Monday 5 November 2018

LESSON 4 Checking whether a string palindrome C Programming

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");
     else
     printf("the string is palindrome");
     getch();
}

0 Comments:

Post a Comment

Facebook Twitter Delicious Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | coupon codes