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
What is vector processing?
Which bit wise operator is suitable for checking whether a particular bit is on or off?
What does std :: flush do?
What is the function of I/O library in C++ ?
Write syntax to define friend functions in C++.
What are c++ tokens?
How should runtime errors be handled in c++?
How c functions prevents rework and therefore saves the programers time as wel as length of the code ?
What is abstraction c++?
How does code-bloating occur in c++?
Give 10 points of differences between C & C++.
Array base access faster or pointer base access is faster?
What is the word you will use when defining a function in base class to allow this function to be a polimorphic function?
What do nonglobal variables default to a) auto b) register c) static
Can c++ do everything c can?