/*=================================================================================
**
** File Name : stringPall.c
** Creation Date : Sat 19 Mar 2016 04:44:11 AM IST
** Last Modified : Sat 19 Mar 2016 04:59:05 AM IST
** Compoler : gcc
** Author : Manoj Kumar Patra, manojpatra.sit@gmail.com
** Organization : SCIS, University of Hyderabad, India.
**
**===============================================================================*/
#include<stdio.h>
#include<string.h>
int main()
{
printf("\n= = = = = C Program to pallindrome check = = = = =\n");
char string[100];
int i, len, stat=0;
printf("\nEnter the String : ");
scanf("%s",string);
len = strlen(string);
for(i=0; i<len; i++)
{
if(string[i] != string[len-i-1])
{
stat = 1;
break;
}
}
if(stat == 1)
{
printf("\n'%s' is NOT a pallindrome\n",string);
}
else
{
printf("\n'%s' is a pallindrome\n",string);
}
printf("\n\n= = = = = = = = = = = = = = = = = = = = = = = = = =\n");
}
OutPut:
max@ubuntu:~/cprog$ gcc stringPall.c -o stringPall
max@ubuntu:~/cprog$ ./stringPall
= = = = = C Program to pallindrome check = = = = =
Enter the String : manoj
'manoj' is NOT a pallindrome
= = = = = = = = = = = = = = = = = = = = = = = = = =
max@ubuntu:~/cprog$ ./stringPall
= = = = = C Program to pallindrome check = = = = =
Enter the String : abcdcba
'abcdcba' is a pallindrome
= = = = = = = = = = = = = = = = = = = = = = = = = =
**
** File Name : stringPall.c
** Creation Date : Sat 19 Mar 2016 04:44:11 AM IST
** Last Modified : Sat 19 Mar 2016 04:59:05 AM IST
** Compoler : gcc
** Author : Manoj Kumar Patra, manojpatra.sit@gmail.com
** Organization : SCIS, University of Hyderabad, India.
**
**===============================================================================*/
#include<stdio.h>
#include<string.h>
int main()
{
printf("\n= = = = = C Program to pallindrome check = = = = =\n");
char string[100];
int i, len, stat=0;
printf("\nEnter the String : ");
scanf("%s",string);
len = strlen(string);
for(i=0; i<len; i++)
{
if(string[i] != string[len-i-1])
{
stat = 1;
break;
}
}
if(stat == 1)
{
printf("\n'%s' is NOT a pallindrome\n",string);
}
else
{
printf("\n'%s' is a pallindrome\n",string);
}
printf("\n\n= = = = = = = = = = = = = = = = = = = = = = = = = =\n");
}
OutPut:
max@ubuntu:~/cprog$ gcc stringPall.c -o stringPall
max@ubuntu:~/cprog$ ./stringPall
= = = = = C Program to pallindrome check = = = = =
Enter the String : manoj
'manoj' is NOT a pallindrome
= = = = = = = = = = = = = = = = = = = = = = = = = =
max@ubuntu:~/cprog$ ./stringPall
= = = = = C Program to pallindrome check = = = = =
Enter the String : abcdcba
'abcdcba' is a pallindrome
= = = = = = = = = = = = = = = = = = = = = = = = = =
No comments:
Post a Comment