Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


I can not get my C++ program to work right. It is supposed
to tell if a word is a palindrome or not, but it only tells
thet the word is not a palindrome. And I can't fix it.



I can not get my C++ program to work right. It is supposed to tell if a word is a palindrome or not..

Answer / sam

#include <iostream>
using namespace std;

int pali (char word[30]);
int main () {

char word[30];
char ans[5];
int answer;

cout << "Please enter a word (in all lowercase letters)"
<< endl;
cin.getline(word,30);

answer = pali(word);
if (answer == 1){
strcpy(ans,"a");
}
else{
strcpy(ans,"not a");
}
cout << " The word you entered was " << ans << "
palidrome" << endl;

}

int pali(char word[30]) {

char flip[30];
int length;
length = strlen(word);

for (int w = length-1, f = 0 ; w > -1; w--, f++) {
flip[f] = word[w];
}
strcmp(word,flip);
if (word == flip) {
return 1;
}
else {
return 0;
}
}

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More C C++ Errors Interview Questions

What is the out put of this programme? int a,b,c,d; printf("Enter Number!\n"); scanf("%d",&a); while(a=!0) { printf("Enter numbers/n"); scanf("%d%d%d",&b,&c,&d); a=a*b*c*d; } printf("thanks!"); getche(); Entering numbers are a=1,b=2,c=3,d=4 b=3,c=4,d=-5 b=3,c=4,d=0

5 Answers   TCS,


what is macro in c? Difference between single linked list & double linked list what is fifo & lifo? what is stack & queue?

2 Answers   TCS,


write a profram for selection sort whats the error in it?

2 Answers  


How to create a program that lists the capital country when told what the original country is? (Terribly sorry, I'm a novice programmer and would appreciate any help ;). Cheers, Alexxis

0 Answers  


How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?

1 Answers  






Given that two int variables, total and amount, have been declared, write a loop that reads integers into amount and adds all the non-negative values into total. The loop terminates when a value less than 0 is read into amount. Don't forget to initialize total to 0. Instructor's notes: This problem requires either a while or a do-while loop.

3 Answers  


what is syntax error?

3 Answers  


what is meant by linking error? how can i solve it? if there is a linking error " unable to open file 'cos.obj'? then what should i do?

1 Answers  


who was the present cheif governor of reserve bank of india

6 Answers   State Bank Of India SBI,


printy(a=3,a=2)

3 Answers  


How to develop a program using C language to convert 8-bit binary values to decimals. TQ

0 Answers   Amazon,


I can not get my C++ program to work right. It is supposed to tell if a word is a palindrome or not, but it only tells thet the word is not a palindrome. And I can't fix it.

1 Answers  






Categories