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 |
what is exceptions?
A sample program using data structure? what is file handling?
Given that two int variables, total and amount , have been declared, write a sequence of statements that: initializes total to 0 reads three values into amount , one at a time. After each value is read in to amount , it is added to the value in total (that is, total is incremented by the value in amount ). Instructor's notes: If you use a loop, it must be a for loop. And if you use a loop control variable for counting, you must declare it.
full c programming error question based problem
quoroum of computer languages?
how to convert decimal to hexadecimal without using arrays just loops
wap for bubble sort
loop1: { x=i<n?(i++):0; printf("%d",i); exit(x); continue; } Error- misplaced continue. Doubt-1.will the exit(x) be executed for all values of x 2.will this statement go out of the program.
who was the present cheif governor of reserve bank of india
6 Answers State Bank Of India SBI,
WHAT WILL BE THE OUTPUT OF THE FOLLOWING QUESTION void main() { int x=4,y=3,z; z=x-- -y; printf("%d%d%d",x,y,z); }
Why are memory errors hard to debug?
Write down the difference between c. Loop and goto statement d. (!0) and (!1) e. (1= =! 1) and (1!=1) f. NULL and !NULL