Input a word and find the word is palindrome or not.
#include <stdio.h>
#include <conio.h>
void main ( )
{
char nm[80], nm1[80];
int i = 0, ln, j, s = 0;
clrscr ( );
printf("\n\n\n\t\t Enter a word....:"); gets (nm);
for ( ln = 0; nm[ln] != '\0'; ln++ );
for ( j = ln - 1; j >= 0; j-- )
{
nm1[ j] = nm[i++];
}
nm1[ln] = '\0';
for ( i = 0; i < ln; i++ )
{
if ( nm[i] != nm1[i] )
{
s = 1;
break;
}
}
if ( s == 0 )
{
printf("\n\n\n\t\t It is a Palindrome word...: %s ", nm);
}
else
{
printf("\n\n\n\t\t It is not a Palindrome word...: %s ", nm);
}
getch ( );
}
Click here to contact us
#include <stdio.h>
#include <conio.h>
void main ( )
{
char nm[80], nm1[80];
int i = 0, ln, j, s = 0;
clrscr ( );
printf("\n\n\n\t\t Enter a word....:"); gets (nm);
for ( ln = 0; nm[ln] != '\0'; ln++ );
for ( j = ln - 1; j >= 0; j-- )
{
nm1[ j] = nm[i++];
}
nm1[ln] = '\0';
for ( i = 0; i < ln; i++ )
{
if ( nm[i] != nm1[i] )
{
s = 1;
break;
}
}
if ( s == 0 )
{
printf("\n\n\n\t\t It is a Palindrome word...: %s ", nm);
}
else
{
printf("\n\n\n\t\t It is not a Palindrome word...: %s ", nm);
}
getch ( );
}
Click here to contact us
No comments:
Post a Comment