A simple "enter your password" program using C++, looking for advise.
I made a simple "enter your password" program using C++ language and the password is "Hello", I want to know if my way for coding is simple enough or is making things more complicated than it needs to be
#include <iostream>
using namespace std;
main()
{
int i ;
string P= "Hello" ; // P=password
string EP ; // EP=entered password
cout << "please enter your password :" ;
for(i=1;i<=5;i++)
{
cin >> EP ;
if (EP==P)
{
cout << '\n' << '\n' << "correct !! " << "welcome to the programe :D !!" ;
i=8 ; //I made it 8 to stop the For loop
}
else
{
if (i==5)
++i ; /*I put the plus 1 so I that when the user try 5 times it wont have "please try again" massage printed again
after the "please leave" one */
else
cout << "wrong password" << '\n' << "please try again :" ;
}
if(i==4) //this just a warning letter before the last try
cout << '\n' << '\n' <<"warning, you have one try left :" ;
}
if(i==7)
cout << '\n' << '\n' << "you've failed to log in, please leave" ;
}