LNK2001 and LNK1120 errors!!!!!

Can someone please help me with this. My friend is teaching em c++ and he wanted me to make a prgoram that does many different things so i made the program below. The problem is, when i try to run it i keep getting the linker errors listed in the title I am using visual studio 2010 on xp. code is below\

thanks in advance!


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.h>
#include <math.h>

using namespace std;

int a;
int b;
float c;
int d;
int g;
int h;
float i;
int e;
float p_theorem (int side_a, int side_b){
	return sqrtf((side_a * side_a)+(side_b * side_b));
}
float p_theorem_reverse (int side_c, int side_d){
	return sqrtf((side_c * side_c)-(side_d * side_d));
}
void game(int x){
	if (x < 5){
		cout<<"Your number is too low"<<endl<<"Please guess again: ";
		cin>>x;
	}
	else if (x > 5){
		cout<<"Your number is too big"<<endl<<"Please guess again: ";
		cin>>x;
	}
	else (x == 5){
		cout<<"Good job, You guessed the number!"<<endl;
		system("PAUSE");
	}
}

void stuff(){
	cout<<"Developed by Ely Eastman"<<endl<<"Computer 35, T.H. Rogers Secondary School, Houston, TX"<<endl;
	system("PAUSE");
}

int main(void)
{
	cout<<"Welcome to the Multi-Function Program"<<endl;
	cout<<"Enter 1 for finding the hypotenuse of a right triangle"<<endl;
	cout<<"Enter 2 for finding the leg of a right triangle"<<endl;
	cout<<"Enter 3 for the Guessing Game Beta"<<endl;
	cout<<"Enter 4 for Developer Information"<<endl;
	cin>>d;

		if (d == 1){
			cout<<"Welcome to the Pythagorean Theorem Solver"<<endl;
			cout<<"Please enter the length of one leg of the triangle: ";
			cin>>a;
			cout<<"Please enter the length of the other leg of the triangle: ";
			cin>>b;
			c = p_theorem(a, b);
			cout<<"The length of the hypotenuse is "<<c<<endl;
			system("PAUSE");
		}

		else if (d == 2){
			cout<<"Welcome to the Reverse Pythagorean Theorem"<<endl
				<<"Please enter the length of the Hypotenuse: ";
			cin>>g;
			cout<<"Please enter the length of the known leg: ";
			cin>>h;
			i = p_theorem_reverse(g, h);
			cout<<"The length of the leg is: "<<i<<endl;
			system("PAUSE");
		}

		else if (d == 3){
			cout<<"Welcome to the Guessing Game Beta"<<endl
				<<"Please guess a number 1-10: ";
			cin<<e;
				game(e);
		}

		else if (d == 4){
			stuff();
		}
		

		return 0;

		}


i dont see anything unusual. do yall?
Last edited on
In line 29 you should only write 'else' instead of 'else(x==5)', and in line 74 you used '<<' instead of '>>'
Other than what was said above, the unusual things I see are:
-You are using the old <iostream.h> header instead of the one without an extension <iostream> which is more up to date.
-You're declaring variables in the gobal namespace (outside of main) but only using them in main...you should just declare them in main instead.
-Your indentation is a little strange. It is best to put the open braces { on their own line to increase readability, and in your main funtion your if and else-ifs are all over-indented.
-Although not wrong, you shouldn't use system() at all, it's bad practice. A much simpler solution is just cin.synch(); cin.ignore();

After you fix that, I'm not sure whether the linker errors will be gone. (pretty sure it was the iostream.h instead of iostream)

You may notice that your program is lacking the ability to do things more than once, for instance your guessing game only gives the player one chance to guess.
Last edited on
Thanks for that. I havent added the loop for the guessing game yet, same for the random function. Also, what line is systym() in? cannot find it
Topic archived. No new replies allowed.