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 |
How to reverse a linked list without using array & -1? Thank you.
UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....
Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;
#include"stdio.h" #include"conio.h" void main() { int a; printf("\n enter a number:"); scanf("%c\n"); getch(); }
how to convert decimal to binary in c using while loop without using array
50 Answers Apple, Aptech, Arwen Tech, BCS, C2D Software, CEC,
full c programming error question based problem
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.
Display this kind of output on screen. 1 0 1 1 0 1 3. Display this kind of output on screen. 1 1 0 1 0 1 4. Display this kind of output on screen. 1 1 0 1 0 1 5.Display this kind of output on screen. 1 2 3 4 5 6 7 8 9 10
Write a program to accept two strings of Odd lengths. Then take all odd characters from one string and even characters from the other and concatenate and produce a string.
char* f() return "hello:"; void main() {char *str=f(); }
Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.
Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?