> Whats the problem in this^ easy program asking for password.?

Whats the problem in this^ easy program asking for password.?

Posted at: 2014-12-18 
Your variable that is holding the right password is an integer (int x) so your program is getting confused and printing the first statement and exiting. Change the primitive of your x variable to String so it can hold the actual word. Then compare using TWO equal signs == not one. One equal sign assigns values. You have declared x already so you don't need to declare it again. Also you need to put two quotes around wow like this: "wow". I haven't programmed in C++ (C and java) but these are some of the errors I can see just by looking. But I don't think you are reading the input right either. With my suggestions it will look something like this:

#include

int main()

{

using namespace std;

cout<< "Enter Password: ";

String x;

cin>>x;

if (x=="wow")

cout<< "Access Granted"<
else

cout<< "Access Denied"<
return 0;

}

Thx!

Here you go:

http://ideone.com/vrjxEZ

#include

int main()

{

using namespace std;

cout<< "Enter Password:";

int x;

cin>>x;

if (int x= wow)

cout<< "Access Granted"<


else

cout<< "Access Denied"<
return x;

}

but with any number or letter i write in password, i get access granted. Why^

Thank you!