Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is public, protected, private in c++?

1145


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....

2417


What is singleton pattern in c++?

989


Do the parentheses after the type name make a difference with new?

1081


Differentiate between C and C++.

1240


What are the restrictions apply to constructors and destructors?

1079


What is atoi?

967


What is istream and ostream in c++?

1125


Why is it called c++?

1032


Explain selection sorting?

1071


What is unary operator? List out the different operators involved in the unary operator.

994


Explain storage qualifiers in c++.

1076


What is an undefined behavior and sequence points

999


What relational operators if statements in c++?

1172


Explain the difference between overloading and overriding?

1136