Code:
#include <iostream>
using namespace std;
int main () {
string queens;
string password = queens;
string int = 1;
string guess;
cout << "Guess the password or enter 1 to exit! \n";
cin >> guess;
while (( guess != password )) && (( guess != (int)) {
cout << "Try again or enter 1 to exit. \n";
} if ((guess == password )) {
cout << "Congratz! That is the correct password! \n";
} else if ( guess == (int)) {
return 0;
}
return 0;
}
Errors:
CS111ShyanBhairoHW3.cpp: In function ‘int main()’:
CS111ShyanBhairoHW3.cpp:6:13: error: expected unqualified-id before ‘=’ token
string int = 1;
^
CS111ShyanBhairoHW3.cpp:10:36: error: expected identifier before ‘(’ token
while (( guess != password )) && (( guess != (int)) {
^
CS111ShyanBhairoHW3.cpp:10:36: error: expected ‘;’ before ‘(’ token
CS111ShyanBhairoHW3.cpp:14:24: error: expected primary-expression before ‘int’
} else if ( guess == (int)) {
^
CS111ShyanBhairoHW3.cpp:14:24: error: expected ‘)’ before ‘int’
CS111ShyanBhairoHW3.cpp:17:1: error: expected ‘)’ before ‘return’
return 0;
^
#include <iostream>
using namespace std;
int main () {
string queens;
string password = queens;
string int = 1;
string guess;
cout << "Guess the password or enter 1 to exit! \n";
cin >> guess;
while (( guess != password )) && (( guess != (int)) {
cout << "Try again or enter 1 to exit. \n";
} if ((guess == password )) {
cout << "Congratz! That is the correct password! \n";
} else if ( guess == (int)) {
return 0;
}
return 0;
}
Errors:
CS111ShyanBhairoHW3.cpp: In function ‘int main()’:
CS111ShyanBhairoHW3.cpp:6:13: error: expected unqualified-id before ‘=’ token
string int = 1;
^
CS111ShyanBhairoHW3.cpp:10:36: error: expected identifier before ‘(’ token
while (( guess != password )) && (( guess != (int)) {
^
CS111ShyanBhairoHW3.cpp:10:36: error: expected ‘;’ before ‘(’ token
CS111ShyanBhairoHW3.cpp:14:24: error: expected primary-expression before ‘int’
} else if ( guess == (int)) {
^
CS111ShyanBhairoHW3.cpp:14:24: error: expected ‘)’ before ‘int’
CS111ShyanBhairoHW3.cpp:17:1: error: expected ‘)’ before ‘return’
return 0;
^