Submit Your Site To The Web's Top 50 Search Engines for Free!       ExactSeek: Relevant Web Search


Flag Counter

Total Pageviews

Tuesday, December 18, 2012

Program to Check Word Palindrome with C

A palindrome is a word, phrase, number, or other sequence of units that may be read the same way in either direction, with general allowances for adjustments to punctuation and word dividers. Composing literature in palindromes is an example of constrained writing. The word "palindrome" was coined from the Greek roots palin (πάλιν; "again") and dromos (δρóμος; "way, direction") by the English writer Ben Jonson in the 17th century. The Greek phrase to describe the phenomenon is karkinikê epigrafê (καρκινικὴ επιγραφή; "crab inscription"), or simply karkinoi (καρκίνοι; "crabs"), alluding to the movement of crabs, such as an inscription that may be read backwards.
Palindromes date back at least to 79 CE, as a palindrome was found as a graffito at Herculaneum, a city buried by ash in that year. This palindrome, called the Sator Square, consists of an entire sentence written in Latin: "Sator Arepo Tenet Opera Rotas" ("The sower Arepo holds works wheels"). It is remarkable for the fact that the first letters of each word form the first word, the second letters form the second word, and so forth. Hence, it can be arranged into a word square that reads in four different ways: horizontally or vertically from either top left to bottom right or bottom right to top left.

So, this is the source code, I use C Language programming

#include <stdio.h>

#define TRUE 1
#define FALSE 0

int main(void) {
    char str[80];
    int i, j, pal;

    printf("input string: ");

    i = 0;
    j = strlen(str) - 1;
    pal = TRUE;

    do {
        if(str[i] != str[j])
            pal = FALSE;

    } while (str[i] == str[j] && i++ <= j--);

        printf("> palindrom");
        printf("> not a palindrom");

    return 0;
screen shoot


Post a Comment