write program for palindrome

Answer Posted / felix

#include<stdio.h>
#include<ctype.h>
#include<string.h>

int isPalindrome( char *s );

int main ( void )
{
int i = 0;
int ch;
char s[100];

while ((ch = getchar()) != '\n') {
if (isalpha(ch)) {
s[i] = ch;
i++;
}
}

if ( isPalindrome(s) == 1) {
printf("Yes, is a palindrome.\n");
} else {
printf("No, not a palindrome.\n");
}

return 0;

}

int isPalindrome( char *s )
{
int i = strlen(s)-1;
int j = 0;

while (j<=i) {
if(s[j] != s[i]) {
return 0;
}
i--;
j++;
}
return 1;
}

Is This Answer Correct ?    114 Yes 85 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is vector processing?

670


Which bit wise operator is suitable for checking whether a particular bit is on or off?

605


What does std :: flush do?

688


What is the function of I/O library in C++ ?

666


Write syntax to define friend functions in C++.

603






What are c++ tokens?

594


How should runtime errors be handled in c++?

611


How c functions prevents rework and therefore saves the programers time as wel as length of the code ?

622


What is abstraction c++?

589


How does code-bloating occur in c++?

751


Give 10 points of differences between C & C++.

623


Array base access faster or pointer base access is faster?

1815


What is the word you will use when defining a function in base class to allow this function to be a polimorphic function?

672


What do nonglobal variables default to a) auto b) register c) static

648


Can c++ do everything c can?

601