0
why the code does not work?
what's is wrong? https://code.sololearn.com/cWe21v67Jtey/?ref=app
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;
}
+ 8
usersr
123
+ 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.
+ 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 : )
+ 1
thanks fixed ,everything is working))