+ 1
make a program to check password entered by user
3 odpowiedzi
+ 2
#include <iostream>
using namespace std;
int main ()
{
string password,enteredpass;
password = "mypassword";
cout<<"Please enter password";
cin>>enteredpass;
if (password == enteredpass)
{
cout<<"Right password!You
may now use the program";
}
else
cout<<"Wrong password! Try again..";
}
This is basic..This is what i understood from what you asked. By the way, add whatever you want at the if
+ 2
this same code as previous one but i have made it loop until u enter the correct password
#include <iostream>
using namespace std;
int main ()
{
string password,enteredpass;
password = "mypassword";
do {
cout<<"Please enter password";
cin>>enteredpass;
if (password == enteredpass)
{
cout<<"Right password!You
may now use the program";
}
else
cout<<"Wrong password! Try again..";
}while(enteredpass != " mypassword" );
return 0;
}
+ 1
Good add,didnt think about that when i wrote it.