If not pointing to else ?

Ok so i am writting a small game and i have a problem

I have it BETA LOCKED with a code and here is my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main (int nNumberofArgs, char* pszArgs[])
{

// This part will make all the int

int nYear = 0;
int nHigh = 0;
int nWeight = 0;

//BETA LOCK

int ncode = 0;

cout << "THIS IS A CLOSED BETA PLEASE ENTER A PASSWORD TO CONTINUE: ";
cin >> ncode;

if (ncode = 0000)
{
    cout << "Access Granded" << endl;

//This part starts the game

cout << "Hello and Welcome to HOT OR NOT console edition" << endl;
cout << "I am your host GLADOS , and here are out judege's" << endl;
cout << "Host #1 : CYLIAN , Host #2 : Adrian and Host #3 : MAKSYMILIAN" << endl;
cout << "Lets START THE SHOW !!!! " << endl;

system ("PAUSE");

//This part asks the user for DOB HIGHT AND WEIGHT

cout << "L" << endl;
cout << "o" << endl;
cout << "a" << endl;
cout << "d" << endl;
cout << "i" << endl;
cout << "n" << endl;
cout << "g" << endl;
cout << "." << endl;
cout << "." << endl;
cout << "." << endl;

system ("PAUSE");

cout << "Please enter Your YEAR of birth: ";
cin >> nYear;
cout << "Please enter you hight in cm : ";
cin >> nHigh;
cout << "And finnaly enter your Weight in kg : ";
cin >> nWeight;


//This part will calculate is the user HOT OR NOT

cout << "Calculating Please Wait" << endl;

if ( ( nYear > 1980 ) && ( nHigh > 190 ) &&  ( nWeight >= 80 ) )
{
    cout << "You are HOT" << endl;
}
else
{
    cout << "You are not hot" << endl;

}

}

else
{
cout << "Incorrect";
}




system ("PAUSE");
return 0;
}


The Bold is the part of the code i hav a problem with

so if i input the code 0000 the game starts but if i input the wrong code the game starts aswell , any sugestions ?

PS i am a begginer at c++
if (ncode = 0000)

should be

if (ncode == 0)

Notice that numbers starting with 0 in C++ are read as octal numbers, not decimal. Because it's zero, that wouldn't make any difference in this case, but if you're working with decimal numbers, make a habit of not using leading zeros.
Thanks

The 0000 was just an example , but why is it == not just an =
= is assignment, == is equality. For instance:

int ncode = 0;

Here, you're telling the compiler to store the value 0 in ncode.

if(ncode == 0)

Here, you're comparing ncode's value with 0.
Oh

Thank you
Topic archived. No new replies allowed.