Function Help

Hey everyone, I need some help with functions. I was instructed to add on to existing code (my addition is at the very bottom). Whenever I compile it, however, the computer ignores what I put at the bottom. How do I get it to read what I added at the very bottom? 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>
#include <cmath>
#include <string>
using namespace std;

// Function prototypes.  Both functions use reference variables as parameters

void doubleNum(int &);
void getNum(int &);
void zValue(double sampleMean, double populationMean, double populationSTDV, double sampleSize);


int main()
{
	int value, wait;

	// Get a number and store its value
	getNum(value);

	// Double the number stored in value
	doubleNum(value);

	// Display the resulting number.
	cout << "The value doubled is " << value << endl;
	cout << "Enter an integer to terminate : ";
	cin >> wait;
	return 0;
}

// ***************************************************************
// * Definition of getNum
// * The parameter userNum is a reference variable.  The user is
// * asked to enter a number, which is stored in userNum
// ***************************************************************

void getNum(int &userNum)
{
	cout << "Enter a number: ";
	cin >> userNum;
}

// ***************************************************************
// * Definition of doubleNum
// * The parameter refVar is a reference variable. The value in
// * refVar is doubled
// ***************************************************************

void doubleNum(int &refVar)
{
	refVar *= 2;
}

//****************************************************************
//
// New Function with Loop (My Addition)
//
//****************************************************************

void zValue(double sampleMean, double populationMean, double populationSTDV, double sampleSize)
{
	const string message1 = "Enter your vaules for the Z score.";
	double totalZ = ((sampleMean - populationMean) / (populationSTDV) / sqrt(sampleSize));
	cout << "Let's calculate the Z value." << endl;
	cout << message1 << endl;
	cin >> sampleMean,
		   populationMean,
		   populationSTDV,
		   sampleSize;
	cout << "The Z value is: " << totalZ << ".\n";

	//Loop
	int Yes = 1;
	int No = 2;
	int exitLoop;
	cout << "Would you like to terminate the program?" << endl;
	cout << "Press '1' for yes and any other number for no.";
	cin >> exitLoop;
	while (exitLoop < 1 || exitLoop > 1)
	{
		cout << message1;
		cin >> exitLoop;
	}


}
The computer isn't necessarily ignoring your function. You have just not called the function from anywhere. Remember you need to call the function just like the other 2 functions are.
Last edited on
Topic archived. No new replies allowed.