#include <iostream>

using namespace std;

int main()
{
    const int password=123;
    const string username = "abc";
    int pass;
    string user;
    cout<< "Enter your username"<<endl;
    cin>>user;
    cout<< "Enter your Password"<<endl;
    cin>>pass;

    if (pass==password) && (user==username)

    {
        cout<< "Access Granted"<<endl;
    }
    else{
        cout<< "username And Password Incorrect"<<endl;
    }
    cout << "Hello world!" << endl;
    return 0;
}

it says there is a problem with the if statement

Try to ask questions properly, with some more detail.

if ((pass==password) && (user==username))

Hello Sir directorabbey;

  1. Add #include <string>

  2. Transfer the:

const string password = "123";
const string username = "abc";

before int main()

  1. On your if statement add () like this

if ((pass==password) && (user==username))

That would work. Cheers!

-zelrick

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.