Please what is wrong with this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please what is wrong with this code

#include <iostream> using namespace std; int main() { int n,w,x,y,z,a; n = w,x,y,z; cin >> w,x,y,z; a = z,y,x,w; if (n!=a){ cout<< w << " is NOT a palindrome" <<endl; } if (n==a){ cout<< w << " is a palindrome" <<endl; } return 0; }

5th Oct 2022, 2:11 PM
Faith Adediji
Faith Adediji - avatar
4 Answers
+ 3
Revise topics about assigning, input taking,... n = w, x, y, z; is incorrect.. cin >> w, x, y, z ; error. Must be like cin >> w >> x >> y >> z ; Next statement is also incorrect. And also where is your calculations to finding polindrome actually?
5th Oct 2022, 2:22 PM
Jayakrishna 🇮🇳
+ 2
int n,w,x,y,z,a; n = w,x,y,z; cin >> w,x,y,z; a = z,y,x,w; Why you taking multiple inputs and you cannot do like this in CPP a= z,y,x,w // not valid it will assign to single value might be some compiler will work fine but only z will be assign to a a= (z,y,x,w) // valid but value will assign from left to right so final value w will be assign to a variable
5th Oct 2022, 2:20 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
Okay, thanks I saw it online and tried it but it only worked for half of the test but I have found a solution now
6th Oct 2022, 9:24 AM
Faith Adediji
Faith Adediji - avatar
0
And I will revise assigning of inputs, thanks
6th Oct 2022, 9:25 AM
Faith Adediji
Faith Adediji - avatar