Whats wrong with 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
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

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

// This part will make all the int

int nYear;
int nHigh;
int nWeight;


//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";
cout << "o";
cout << "a";
cout << "d";
cout << "i";
cout << "n";
cout << "g";
cout << ".";
cout << ".";
cout << ".";

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";

if (nYear < 1980)(nHigh < 190) (nWeight < 80)

    cout << "You are HOT";

else

    cout << "You are not hot";






system ("PAUSE");
return 0;
}


Error Log
1
2
3
4
5
6
7

Compiling: main.cpp
C:\Users\Adek\Desktop\Beginning_Programing-CPP\Old or not\main.cpp: In function 'int main(int, char**)':
C:\Users\Adek\Desktop\Beginning_Programing-CPP\Old or not\main.cpp:53: error: '(nHigh <= 189)' cannot be used as a function
C:\Users\Adek\Desktop\Beginning_Programing-CPP\Old or not\main.cpp:55: error: expected ';' before 'cout'
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 0 warnings
For one of your errors, on line 53 you've got

"if (nYear < 1980)(nHigh < 190) (nWeight < 80)"
try putting a semi colon (;) on the end of that.

Not sure about the other error though.
Ok it did help but now i get tis error
1
2
3
4
5
6
7
8

Compiling: main.cpp
C:\Users\Adek\Desktop\Beginning_Programing-CPP\Old or not\main.cpp: In function 'int main(int, char**)':
C:\Users\Adek\Desktop\Beginning_Programing-CPP\Old or not\main.cpp:53: error: '(nHigh <= 189)' cannot be used as a function
C:\Users\Adek\Desktop\Beginning_Programing-CPP\Old or not\main.cpp:57: error: 'else' without a previous 'if'
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 0 warnings
 

see logical operators http://cplusplus.com/doc/tutorial/operators/

1
2
3
4
5
6
7
if (nYear < 1980)(nHigh < 190) (nWeight < 80)

    cout << "You are HOT";

else

    cout << "You are not hot";


should be

1
2
3
4
5
6
7
8
if ( ( nYear < 1980 ) && ( nHigh < 190 ) &&  ( nWeight < 480 ) )
{
    cout << "You are HOT";
}
else
{
    cout << "You are not hot";
}


also you should initialize your ints... it won't make much of a difference here but it's good practice

1
2
3
int nYear;
int nHigh;
int nWeight;


should be

1
2
3
int nYear = 0;
int nHigh = 0;
int nWeight = 0;


aside from that you are doing other weird stuff. Go outside and walk around for a while or something then come back and read your code a couple times and ask yourself... "WTF?!?"
Alright man, I took some time and edited a bit in the program, It's much better now. It will now tell you what is wrong with you instead of "You're not hot!" and it actually RUNS xD.

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
#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;


//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\n";
cout << "o\n";
cout << "a\n";
cout << "d\n";
cout << "i\n";
cout << "n\n";
cout << "g\n";
cout << ".\n";
cout << ".\n";
cout << ".\n";

system ("PAUSE");

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


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

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

if (nYear < 1980)
	{
		if(nHigh < 190)
		{
			if(nWeight < 80)
			{
	cout << "You are HOT";
			}
			else
			{
			cout << "You're too fat!" << endl;
			}
		}
		else
		{
		cout << "You're too tall!" << endl;
		}
	}
	else
	{
	cout << "You're too old!" << endl;
	}

system ("PAUSE");
return 0;
}


One thing I don't understand is why you were doing a new cout for each letter in Loading... but you didnt have new lines... why not just write it
cout << "Loading" << endl;?
Topic archived. No new replies allowed.