Let L = length of the string.
greatest integer (L/2) gives the number of pairs of characters that must be compared.
For example if there are 10 letters 10/2 = 5.
abcdeedcba
If there are 11 letters, 11/5= 5.5, also 5. The 6th letter won't matter in this palindrome because it doesn't have to match another character.
abcdefedcba
Once we have the number of pairs [L/2], we need only run a loop,
as 'i' goes from 1 to [L/2]
check that "character i" = "character L+1-i"
Chat with our AI personalities
1. Generate a random word of length n
2. Take generated word and make a copy
3. Reverse copied word
4. Append to original word
a write the algorithm to concatenate two given string
Return an iterator to the string if it exists, or the container's end iterator if it does not.
there is no such method using string copy
Algorithm Step1: Read A, B, C Step2: If A > B is True, then check whether A > C, if yes then A is greatest otherwise C is greatest Step3: If A > B is False, then check whether B > C, if yes then B is greatest otherwise C is greatest Give the Flowchart Answer
/*To check whether a string is palindrome*/includeincludevoid main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }