Userid-password match with common mismatch message
Matching of userid and password in the same condition and if not matched giving a common mismatch message.
Learning Objectives
- Learning to use if-else for matching of userid and password with a common message for any of the entry to be incorrect.
Source Code
|
Alternate (?) : Related (?) : |
Run Output
Code Understanding
if(id==id1 && pw==pw1) cout<<“Access Granted”<<endl;
One single condition check for both user id and password.
else cout<<“userid or password incorrect”<<endl;
One common message if any of the things of userid and password is wrong.
Notes
- This code works well for users who want to give common message for any mismatch. For different message we may have to use nested if, as you can see by pressing the alternate code icon.
Common Errors
- Two conditions must be qualified with && operator. The || operator will give incorrect results.
Suggested Filename(s): userid-pass-cmsg.cpp
sunmitra| Created: 27-Dec-2017 | Updated: 15-Sep-2018|