Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
C++ Problem
#include <cstdlib> #include <iostream>
using namespace std;
int main(void) { ;int iPassword; ;int iPassword2; ;int iPassword3; while(true) (
cout << "Please enter the password: " ) << endl;
cin >> iPassword
;if(iPassword = 255)
(
cout << "That is correct." << endl);
if (iPassword < 255 | iPassword > 255)
(
cout << "That is incorrect, please try again." << endl);
cout << "Please enter the second password: " << endl;
cin >> iPassword2
;if(iPassword2 = 916)
(
cout << "That is correct.") << endl;
if (iPassword2 < 916 | iPassword2 > 916)
(
cout << "That is incorrect, please try again." << endl << endl);
;if(iPassword3 = 5131)
(
cout << "ACCESS GRANTED" << endl << endl);
if (iPassword3 < 5131 | iPassword3 > 5131)
(
cout << "That is incorrect, please try again." << endl << endl);
system("PAUSE");
return 0;
}
Yes, At a glance I found four.
#include <cstdlib>
#include <iostream>
using namespace std;
int main(void)
{
int iPassword; // also just noticed that you had ; at the beginning, don't put then there.
int iPassword2;
int iPassword3;
while(true)
(
cout << "Please enter the password: " << endl; // the parentheses
cin >> iPassword;
if(iPassword == 255)
// you had to set this as == not = or it will set it as 255
(
cout << "That is correct." << endl);
if (iPassword < 255 | iPassword > 255)
(
cout << "That is incorrect, please try again." << endl);
cout << "Please enter the second password: " << endl;
cin >> iPassword2;
if(iPassword2 == 916) //same here
(
cout << "That is correct.") << endl;
if (iPassword2 < 916 | iPassword2 > 916)
(
cout << "That is incorrect, please try again." << endl << endl);
if(iPassword3 == 5131) // and here and an extra ; at the begining
(
cout << "ACCESS GRANTED" << endl << endl);
if (iPassword3 < 5131 | iPassword3 > 5131)
(
cout << "That is incorrect, please try again." << endl << endl);
system("PAUSE");
return 0;
}```
skathgh420 wrote: Correct me if I'm wrong but it looks like there's a lot of mistakes in this program. Indeed there are, I couldn't quite get my head around it all. SpeedyJ250, if you're just getting the feel of C++ I'd suggest you'd start off by doing something simpler just to get the hang of the individual functions you're trying to use. Also what yours31f said about using two = signs when comparing, same goes for most other things as well, such as |, which could in your attempt be easily replaced with an "else" statement.