Coders Packet

Login to the System using C++

By Shivaani Mathan Kandasamy

In this C++ program, you can log in to the system by using Username and Password. If login credentials match then the user is logged in else error message prompts.

This is a simple C++ program for beginners who wants to learn about if....else statements.

The user should enter the login credentials firstly. If the login credentials match the system then the user is logged in. If wrong credentials are given then the error message prompts.

Both Username and Password should be entered correctly for a successful login. If anyone is also wrong then an error message prompts.

Program Summary

  1. Enter Username and Password.
  2. If valid credentials are entered then the user can log in.
  3. Else error message prompts.



using namespace std;
int main()
    int i, password;
    string username;
    char ch;
    cout<<"\n---------------------------------------- ";
    cout<<"\n \t\t WELCOME !";
    cout<<"\n\n\t Enter your Login Credentials";
    cout<<"\n Enter your Username : ";
    cout<<"\n Enter your Password : ";
        if(username == "Shivaani" && password == 123)
        cout<<"\n Logged in Successfully";
        else if(username == "Shiva" && password == 456)
        cout<<"\n Logged in Successfully";
        else if(username == "Ram" && password == 789)
        cout<<"\n Logged in Successfully";
        cout<<"\n Wrong Credentials";
        cout<<"\n Do you want to Enter Login Detais again ? (y/n).. ";
    while(ch=='y' || ch=='Y');
    return 0;




Download Complete Code


No comments yet