Thursday, November 21, 2013

             
           Logical Operators: AND(&&) OR(||) NOT(!) in c++

#include <iostream>
#include <string>

using namespace std;

const string userName = "computergeek";
const string passWord = "break_codes";

int main ()
{
    string name, pass;

    cout << "Username: ";
    cin >> name;

    cout << "Password: ";
    cin >> pass;

    if (name == userName && pass == passWord)
    {
        cout << "You are logged in!" << endl;
    }

    else
        cout << "Incorrect username or password." << endl;

    return 0;
}


No comments:

Post a Comment