0

why the code does not work?

what's is wrong? https://code.sololearn.com/cWe21v67Jtey/?ref=app

10th Mar 2018, 2:11 PM
Юрий Лисовский
Юрий Лисовский - avatar
5 Answers
+ 8
Your code had a few errors 1. you declared name as int it should be string 2. you wrapped the comparison between quotation marks. it should have been the value you were comparing "user" in this case. //Corrected code below #include <iostream> using namespace std; // code by Y.l. // date 10.3.2018 int main() { string name; int password; cout <<"Enter a name \n "; cin >> name; cout <<"Enter a password \n"; cin >> password; if(name == "user" && password == 123) { cout <<"dobro pojalovat" << endl; } else { cout <<"neverno" << endl; } return 0; }
10th Mar 2018, 2:28 PM
Lord Krishna
Lord Krishna - avatar
+ 8
usersr 123
10th Mar 2018, 2:33 PM
Manual
Manual - avatar
+ 7
It works for me. You may be having an issue with inputing values. for multiple inputs on sololearn example: input [ PRESS ENTER ] input2 [ PRESS submit ] copy and paste my next answer for the input.
10th Mar 2018, 2:32 PM
Manual
Manual - avatar
+ 5
Also if you want to use alphabet for the password you better use string as well, then you can compare it like you did compare the name : )
10th Mar 2018, 2:37 PM
Ipang
+ 1
thanks fixed ,everything is working))
10th Mar 2018, 3:04 PM
Юрий Лисовский
Юрий Лисовский - avatar