¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita0
Fix and tell me what you did to make it work, kinda at the end of the line with this C++ not doing what I want D:<
#include <iostream> using namespace std; int main() { int a; cout << "Enter Code" << endl; cin >> a; if (a=876) cout << "Welcome." << endl; else cout << "Error 876: Wrong Code" << endl; }
2 Respuestas
+ 1
You need to use 'if(a == 876)' instead of 'if(a=876)'. That == is comparison operator, = is assignment operator. You are assigning value of 876 to variable a in that if statement. This returns 876, which is not 0, so it's true, so that code after if statement won't be executed only if user inputs 0.
0
Missing some curly brackets.