#include <stdio.h>
#include <conio.h>
#include <string.h>
void input(char a[ ])
{
int i;
printf("\n enter string\n");
scanf("%s",a);
}
void output(char a[ ])
{
printf("\n string is %s",a);
}
int palindrome(char a[ ])
{
int n,i;
n=count(a);
n=n-1;
i=0;
for(;a[n]==a[i] && n>=i;i++,n--);
if(n>=i)
return 0;
else
return 1;
}
void main( )
{
char a[80],b[80],s;
int n;
printf("\n check palindrome");
input(a);
n=palindrome(a);
output(a);
if(n==1)
printf("\n palindrome");
else
printf("\n not palindrome");
getch();
}
An algorithm can not be written with the following infix expression without knowing what the expression is. Once this information is included a person will be able to know how to write the algorithm.
You can write 2X, where X is the length of the string.
dejene
1. sort desc, so a1 >= a2 >= a3 2. check if (a1*a1 == a2*a2 + a3*a3) then true
You cannot list them: unless the inequality is trivial, since there are infinitely many real numbers in any range. You need toidentify the lower bound;determine whether or not the lower bound is included (
def isPalindrome(s): return s == s[::-1] then just call the function with a string like isPalindrome('poop')
You can do this: <?php if ( $word === strrev( $word ) ) { echo "The word is a palindrome"; } else { echo "The word is not a palindrome"; }
a write the algorithm to concatenate two given string
It is a simple program. i think u may understand it :#include#include#includevoid main(){char s[10]=answers.com;char x[10];int a;clrscr();strcpy(x,s);strrev(s);a=strcmp(s,x);if(a==0){printf("the entered string is palindrome");}else{printf("the entered string is not palindrome");}output:given string is not palindrome
If you want to check whether a string is a palindrome, you can reverse the string (for example, the Java class StringBuffer has a reverse() method), and then compare whether the two strings - the original string and the reverted string - are equal. Alternately, you could write a loop that checks whether the first character of the string is equal to the last one, the second is equal to the second-last one, etc.; that is, you have a counter variable (in a "for" loop) that goes from zero to length - 1 (call it "i"), and compare character #i with character #(length-i-1) inside the loop.
You can write out this algorithm. This will then be programmed into the device to make determining prime numbers easier.
Prepare the string for processing: Remove all punctuation from the string (e.g., commas, hyphens, whitespace, etc). Convert to the same case (e.g., lower-case). Instantiate two pointers, one pointing at the first character, the other pointing at the last character. Process: If the two pointers are pointing at the same position or have crossed each other, the string is a palindrome. Otherwise, compare the characters being pointed at. If they are not equal, the string is not a palindrome. Otherwise, move both pointers one position towards the middle of the string and repeat the process.
sdfdg
Copy and reverse the string. If the reversed string is equal to the original string, the string is a palindrome, otherwise it is not. When working with strings that hold natural language phrases (including punctuation, whitespace and so on) we must remove all the non-alphanumerics and convert the remainder to a common case, such as lower-case, prior to copying and reversing the string.
Palindrome number is a number like 121 which remains the same when its digits are reversed. To find this number in a simple java program, just follow the below way. sum = 0; while(n>0) { r=n % 10; sum=concat(r); n=n / 10; } print r;
Write your program and if you are having a problem post it here with a description of the problem you are having. What you are asking is for someone to do your homework for you.
You don't have to write palindrome programs in wikipedia.