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 does asterisk mean in c++?
Why is c++ so fast?
How does c++ sort work?
. If employee B is the boss of A and C is the boss of B and D is the boss of C and E is the boss of D. Then write a program using the Database such that if an employee name is Asked to Display it also display his bosses with his name. For eg. If C is displayed it should also display D and E with C?
Can circle be called an ellipse?
What is abstraction in c++ with example?
What is public, protected, private in c++?
can any one help to find a specific string between html tags
which is changed to a sting..
weather.html looks (for location) is
Comment on assignment operator in c++. Which software is best for programming? What sorting algorithm does c++ use? What is a memory leak c++? What is the difference between a "copy constructor" and an "assignment operator" in C++? What are 2 ways of exporting a function from a dll? Do you need a main function in c++?