This is C program for Palindrome number which is check whether number or string is palindrome or not. Palindrome means given number which is same as reverse number.
eg. 12321==12321 Palindrome number
nitin==nitin Palindrome string
12345==54321 Not palindrome number
cool==looc Not palindrome string
This palindrome program is created without string header file or string function.
eg. 12321==12321 Palindrome number
nitin==nitin Palindrome string
12345==54321 Not palindrome number
cool==looc Not palindrome string
This palindrome program is created without string header file or string function.
Program for palindrome:-
#include<stdio.h>
|
int main()
|
{
|
int i,j,n,flag;
|
char word[50],ch;
|
do{
|
n=0;
|
flag=0;
|
printf("\nEnter any word or number to check
palindrome=");
|
scanf("%s",word);
|
for(i=0;word[i]!='\0';i++)
|
n++;
|
for(i=0,j=n;i<n/2;i++,j--)
|
{
|
if(word[i]!=word[j-1])
|
{
|
printf("\nIt is Not palindrome word or number");
|
flag=1;
|
break;
|
}
|
}
|
if(flag==0)
|
printf("\nIt is palindrome word or
number");
|
printf("\nDo you want to check any other word
or number(y/n)=");
|
scanf("\n%c",&ch);
|
}while(ch=='y'||ch=='Y');
|
printf("\nThank you...\n");
|
return 0;
|
}
|
Output:-
Please comment and give
Suggestion on this post, if you want any other program or help then type in
comment or contact me, and give feedback for this blogs.
No comments:
Post a Comment