0% found this document useful (0 votes)
148 views

Palindrome

The document defines and provides examples of palindromes. A palindrome is a word, phrase, or sequence of characters that reads the same backward or forward, ignoring punctuation, capitalization, and spacing. Examples of palindromic words, phrases, numbers, dates, and longer compositions are given. The document also notes that some individuals have palindromic names and fictional characters with palindromic names.

Uploaded by

Zy Adrianne
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views

Palindrome

The document defines and provides examples of palindromes. A palindrome is a word, phrase, or sequence of characters that reads the same backward or forward, ignoring punctuation, capitalization, and spacing. Examples of palindromic words, phrases, numbers, dates, and longer compositions are given. The document also notes that some individuals have palindromic names and fictional characters with palindromic names.

Uploaded by

Zy Adrianne
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

PALINDROME

Informally speaking, a palindrome is a word, phrase, or


sentence that reads the same backwards as it does forwards.
Punctuation, whitespace, and all other characters other than
letters are generally ignored, and upper-case letters are
considered the same as the equivalent lower-case letters

A palindromic number is a number where the digits, with


decimal representation usually assumed, are the same read
backwards, for example, 58285. They are studied in recreational
mathematics where palindromic numbers with special properties
are sought. A palindromic prime is a palindromic number that is a
prime number.

Palindromic dates are of interest to recreational


mathematicians and numerologists, and sometimes generate
comment in the general media.[4] Whether or not a date is
palindromic depends on the style in which it is written. For
example, in the dd/mm/yyyy style, the 20th February 2002 (20-
02-2002) was palindromic.

Some palindromes use words as units rather than letters.


Examples are "fall leaves after leaves fall" and "First Ladies rule
the State and state the rule: ladies first". The command "Level,
madam, level!", composed only of words that are themselves
palindromes, is both a character-by-character and a word-by word
palindrome.

The most familiar palindromes, in English at least, are


character-by-character: the written characters read the same
backwards as forwards. Palindromes may consist of a single word
(civic, level, Malayalam), or a phrase or sentence ("Neil, a trap!
Sid is part alien!", "Was it a rat I saw?", "Mr. Owl ate my metal
worm", "Sit on a potato pan, Otis."). Spaces, punctuation and case
are usually ignored. Much longer palindromic compositions have
been constructed; see "Long palindromes", below.
Three famous English palindromes are "Able was I ere I saw
Elba"[1] (which is also palindromic with respect to spacing), "A
man, a plan, a canal—Panama!”[2], and “Madam, in Eden I'm
Adam,”[3]. The last example is still palindromic if "in Eden" is
omitted; the response is either the one-word palindrome, "Eve," or
the more obscure "Name no one man."

Some individuals have names that are palindromes. Some


changed their name in order to be a palindrome (one example is
actor Robert Trebor), while others were given a palindromic name
at birth (such as Neo-Nazi philologist Revilo Oliver). Fictional
names include Stanley Yelnats, the main protagonist in the book
Holes by Louis Sachar.

SAMPLE PROGRAMS
#include<stdio.h>
#include<string.h>
#define size 100

int main()
{
char temp1[size];
char temp2[size];
int i;
int j=0;
int k=0;
printf("\n Enter String:= ");
scanf("%s",temp1);
while(temp1[k++]!='\0');
k--;

for(i=k-1;i>=0;i--)

{
temp2[j]=temp1[i];
j++;
}

printf("The palindrome of the given input is:\n%s",temp2);

SORTING OF ARRAYS
The last parameter specifies whether to sort array in
ascending or descending order. The "greater than" symbol (>)
indicates an ascending sort; the "less than" symbol (<) indicates
a descending sort. If you do not specify the sorting order, then the
sort is ascending.

If more than one array is specified, the arrays are sorted


following the sort order of the first array; no multi-level sorting is
performed here. This feature is especially useful with grouped
scrollable areas in a form; SORT ARRAY maintains the
synchronicity of the arrays that sustain the scrollable areas.

Array sorting techniques require much of the same thinking


skills as searching. The most important aspect by far is simply
knowing how to manipulate an array. By definition, an array is a
homogeneous structure consisting of a collection of memory
locations used to store data values all of the same type. In
particular, the programmer will also need to be aware of how
arrays store data using index or subscript values. Arrays always
have a beginning subscript value and a terminating ending value.
These subscript values make up the "range" of the array. For
instance in C++, an array always has a beginning subscript value
of zero. In other languages such as Ada, the beginning subscript
value doesn't have to be zero. The programmer will also need to
be comfortable with looping, especially for loops. When
investigating the bubble sort, we will see how "nested" loops, loop
structures within another loop structure, come into play. As with
searching, array sorting will require the algorithm to traverse the
"range" of the array while sorting array elements. We are most
concerned with the method used to sort while traversing the
array. The size of the array should also be known by the
programmer. Here again just like searching, it is sometimes best
to declare the array size as a global constant. If familiar with array
and for loop logic, the code should be fairly straightforward to
understand. I recommend using your "mind" to execute the code
using sample data with pen and paper before attempting any
actual program compilations. This will force you to fully
understand the concept of sorting.

SAMPLE PROGRAMS
/* add.c -- Read a sequence of positive integers and print them
* out together with their sum. Use a Sentinel value
* (say 0) to determine when the sequence has terminated.
*/

#include <stdio.h>
#define SENTINEL 0

int main(void) {
int sum = 0; /* The sum of numbers already read */
int current; /* The number just read */

do {
printf("\nEnter an integer > ");
scanf("%d", &current);
if (current > SENTINEL)
sum = sum + current;
} while (current > SENTINEL);
printf("\nThe sum is %d\n", sum);
}
SAMPLE PROGRAMS
/* power2.c -- Print out powers of 2: 1, 2, 4, 8, .. up to 2^N
*/

#include <stdio.h>
#define N 16

int main(void) {
int n; /* The current exponent */
int val = 1; /* The current power of 2 */

printf("\t n \t 2^n\n");
printf("\t================\n");
for (n=0; n<=N; n++) {
printf("\t%3d \t %6d\n", n, val);
val = 2*val;
}
return 0;
}

/* It prints out :

n 2^n
================
0 1
1 2
2 4
3 8
4 16
5 32
6 64
7 128
8 256
9 512
10 1024
11 2048
12 4096
13 8192
14 16384
15 32768
16 65536

*/
RESEARCH
IN
D.S.A
#16
7:30-9:00am Lab
8:00-9:00am Lec

You might also like