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 it mean to declare a member function as virtual?
Which coding certification is best?
What are the various oops concepts in c++?
Describe friend function & its advantages.
Explain about Virtual Function in C++?
What are structs in c++?
Explain "const" reference arguments in function?
What is the main function c++?
What is algorithm in c++ programming?
What are stacks? Give an example where they are useful.
What is the array and initializing arrays in c++?
What are virtual functions in c++?
Differentiate between realloc() and free().
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)