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 function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor
Can I learn c++ without c?
What is a manipulative person?
Is c++ built on c?
Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].
What is c++ virtual inheritance?
Explain the uses of static class data?
Can we specify variable field width in a scanf() format string? If possible how?
What are the advantages of using friend classes?
Which is not an ANSII C++ function a) sin() b) tmpnam() c) kbhit()
When should I use unitbuf flag?
what is C++ objects?
What are move semantics?
What is doubly linked list in c++?
How do you define/declare constants in c++?