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


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

void main() { int i=7; printf("N= %*d",i,i); }

6 Answers   HCL,


I am using Qt 5.6 during compilation it stops and gives error about Qmake The process "C:QtQt5.6.35.6.3msvc2015_64inqmake.exe" crashed. Error while building/deploying project untitled1 (kit: Desktop Qt 5.6.3 MSVC2015 64bit) When executing step "qmake"

0 Answers  


void main() { int i=5; printf("%d",i+++++i); }

14 Answers   HCL,


how to convert decimal to hexadecimal without using arrays just loops

2 Answers  


Write down the difference between c. Loop and goto statement d. (!0) and (!1) e. (1= =! 1) and (1!=1) f. NULL and !NULL

0 Answers  


Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?

2 Answers  


quoroum of computer languages?

0 Answers   Infosys,


void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?

24 Answers   HCL,


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

2 Answers   TCS,


what is syntax error?

3 Answers  


char* f() return "hello:"; void main() {char *str=f(); }

1 Answers  


Why are memory errors hard to debug?

1 Answers  


Categories