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 public, protected, private in c++?
In inline " expression passed as argument are evalauated once " while in macro "in some cases expression passed as argument are evaluated more than once " --> i am not getting it plz help to make me understand....
What is singleton pattern in c++?
Do the parentheses after the type name make a difference with new?
Differentiate between C and C++.
What are the restrictions apply to constructors and destructors?
What is atoi?
What is istream and ostream in c++?
Why is it called c++?
Explain selection sorting?
What is unary operator? List out the different operators involved in the unary operator.
Explain storage qualifiers in c++.
What is an undefined behavior and sequence points
What relational operators if statements in c++?
Explain the difference between overloading and overriding?