Please tell about Writing a program how to check planidrome dynamically?
Note : This is the question asked by a visitor Venkat. I am posting this in proper forum.
Please tell about Writing a program how to check planidrome dynamically?
Note : This is the question asked by a visitor Venkat. I am posting this in proper forum.
1) read string to an array variable.
2) calculate the length of the string using proper string function!
3) set two integer variables point to start & end of the string array!
4) use a FOR loop to increment & decrement start and end variables respectively until start = end or start > end!
5) compare both characters in each cycle and if not same it means the string is not palindrome.
6) Print result!
Now, try to code yourself....Anyway I'll help you...
Regards,
Anoop :)
If its useful, dont forget to [COLOR="Red"]THANK[/COLOR] me :cool:
Program to check for palindrome
#include < stdio.h >
#include < string.h >
#include < stdlib.h >
#include < ctype.h >
int isPalindrome(char string[]);
int main()
{
isPalindrome("avon sees nova");
isPalindrome("a");
isPalindrome("avon sies nova");
isPalindrome("aa");
isPalindrome("abc");
isPalindrome("aba");
isPalindrome("3a2");
return(0);
}
int isPalindrome(char string[])
{
int count, countback, end, N;
N = strlen(string);
end = N-1;
for((count=0, countback = end); count <= (end/2); ++count,--countback)
{
if(string[count]!=string[countback])
{
return(1);
}
}
printf("\n[%s] is a palidrome!\n", string);
return(0);
}