0

If statement problem

can anyone explain why if statement in c++ didn't work? but my code is right (no error' syntax)

19th Oct 2018, 11:30 PM
Alpha
Alpha - avatar
5 Antworten
+ 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..
20th Oct 2018, 8:51 AM
jay
jay - avatar
+ 4
Please show your code
19th Oct 2018, 11:33 PM
jay
jay - avatar
+ 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
20th Oct 2018, 10:11 AM
stamb
stamb - avatar
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
20th Oct 2018, 12:05 AM
Alpha
Alpha - avatar
0
and 4) <iostream>
20th Oct 2018, 10:15 AM
stamb
stamb - avatar