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
How does a C++ structure differ from a C++ class?
Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?
How does atoi function work?
Is swift better than c++?
Can a list of string be stored within a two dimensional array?
What is the most powerful coding language?
How can you quickly find the number of elements stored in a static array?
Who discovered c++?
What is an html tag?
Name the implicit member functions of a class.
What is #include iostream?
What is the protected keyword used for?
What is the difference between an external iterator and an internal iterator?
Difference between inline functions and macros?
What is the difference between public and private data members?