+ 2

Password checking doesn't work.

Hi! Im at very beggining of learning c++. I've just made this simple program which check if password is correct. Problem is output is always "Access granted". Can anyone show me what's wrong? Thanks! #include <iostream> using namespace std; int main() { int pass; cout << "Enter Password"<<endl; cin >>pass; if (pass=159875321){ cout <<"Access granted"<<endl; } else { cout<<"Access denied"<<endl; } return 0; }

14th Sep 2017, 4:59 PM
Hubert Łukaszewicz
Hubert Łukaszewicz - avatar
2 Respostas
+ 17
of course you forgot to add another equal sign for comparison '=' https://code.sololearn.com/cQn35AKp2QfI/?ref=app
14th Sep 2017, 5:06 PM
Lord Krishna
Lord Krishna - avatar
+ 1
Big thanks!
14th Sep 2017, 5:07 PM
Hubert Łukaszewicz
Hubert Łukaszewicz - avatar