Function Fun Mysterious Error

Hey all so I'm writing a program demonstrating function calling in main. I tried building it but I got an error message I cannot decipher. here it is:

1>Function_Fun.obj : error LNK2019: unresolved external symbol "int __cdecl getInteger(int,int)" (?getInteger@@YAHHH@Z) referenced in function _main

1>C: : fatal error LNK1120: 1 unresolved externals

Any ideas what I'm doing wrong here?

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
86
87
88
89
90
91
92
93
94
95
96
97
98
#include<iostream>
#include<iomanip>

using namespace std;

// function prototyping
int getInteger(int Height,int Width);
void printRangeAndAvg(int Low, int High); 
void printBox(int Height, int Width); 
void printWedge(int Height);

void main()
{
	//create variables
	int Width;
	int Height;
	
cout << "Enter box height (between 3 and 10): ";
    Height = getInteger(3, 10);
cout << "Enter box width (between " << Height << " and 20): ";
    Width = getInteger(Height + 1, 20);
	printRangeAndAvg(Height, Width);
    printBox(Height, Width);
    printWedge(Height);

	//keep the console open
	cin.get();
	cin.ignore();
}

int getInteger(int Height)
{
	//prompt user for integer between low and high value
	cout << "Enter a box height(between 3 and 10):";
	cin >> Height;

	//prompt user to repeat height if out of bounds
	while(Height  < 3 || Height > 10)
	{
		cout << "That number is out of bounds: Try height again: ";
		cin >> Height;
	}
	return Height;
}

void printRangeAndAvg(int Height, int Width)
{
	int NumSum = 0;
	int NumCount = 0;
	float Average;

	//output the integers between height and width
	cout << "\nThe integers between " << Height << " and " << Width
	<< " are:" << endl <<"\t";
	//calculate the number of numbers between height and width
	NumCount = (Width - Height) + 1;

	//calculate sum  of integers between height and width
	for (int i=Height; i<=Width; i++)
	{
		cout << i << " ";
		NumSum = NumSum+i; 
	}
	cout << endl;

	//calculate the average of numbers between height and width 
	Average = static_cast<float>(NumSum) / NumCount;
	cout << "and the average of those numbers is " << Average << endl << endl;
}

void printBox(int Height, int Width)
{
	//define local variable
	char Asterisk = '*';

	//output hollow rectangle with user input height and width
	cout << Asterisk << setw(Width-1) << setfill ('*') << Asterisk << endl;
	for(int a=0; a<Height-2; a++)
	{
		cout << Asterisk << setw(Width-1) << setfill(' ') << Asterisk << endl;
	}
	cout << Asterisk << setw(Width-1) << setfill ('*') << Asterisk << endl;
	cout << endl;
}

void printWedge(int Height)
{
	//Output triangle with row = height, starting with 2 asterisks on top
	for (int x=1; x<=Height; x++)
	{

		for(int y=1; y<=x+1; y++)
				{
					cout << "*";
				}
		cout << endl;
	}
}
closed account (SECMoG1T)
You repeated almost the same error again haha

1
2
3
4
int getInteger(int Height,int Width);//your prototype declaration line 7
Height = getInteger(3, 10);/// you called this function in line 19 and 21
/// prblm is your above function isn't defined any where
 int getInteger (int Height); //line 31 doesn't match your function calls in main 


/// you can redefine your function to take an extra arg or simply overload it
Last edited on
Topic archived. No new replies allowed.