0
If statement problem
can anyone explain why if statement in c++ didn't work? but my code is right (no error' syntax)
5 Answers
+ 6
What is the input required to trigger good or bad answers?
Anyway, as both of these variables (good and bad) are uninitialized, matching any input the user enters will be nigh impossible..
+ 4
Please show your code
+ 1
Next errors:
1) main() and at the end of program must be }.
2) string instead of int , i.e. : string good="good",bad="bad",answer,username;
3) cin>>username; instead of user
0
this the code :
#include iostream
using namespace std;
int main
{
int pass;
int username;
string user = "Farizi";
int good;
int bad;
int answer;
pass= 12345;
int i;
cout << "username";
cin >> user;
cout << "password";
cin >> pass;
if(pass == 12345 && username == user){
cout<< "welcome Fariz " << endl;
cout << "how are you" << endl;
cin >> answer;
if(answer == good){
cout << "good to hear that " << endl;
}
if(answer == bad){
cout << "sorry to hear that" << endl;
}
}
else{
cout << "you cannot enter" << endl;
cout << "please exit" << endl;
}
the if statement : if(answer== bad) not working
this one of many other of if statement problem i cannot solve it
please help
0
and 4) <iostream>