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.
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 |
void main() { int i=7; printf("N= %*d",i,i); }
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"
void main() { int i=5; printf("%d",i+++++i); }
how to convert decimal to hexadecimal without using arrays just loops
Write down the difference between c. Loop and goto statement d. (!0) and (!1) e. (1= =! 1) and (1!=1) f. NULL and !NULL
Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?
quoroum of computer languages?
void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
what is macro in c? Difference between single linked list & double linked list what is fifo & lifo? what is stack & queue?
what is syntax error?
char* f() return "hello:"; void main() {char *str=f(); }
Why are memory errors hard to debug?