use of Library and void

background: intro C++ student.
we needed to create a library with the (- void increasing (double& A, double& B, double& C); //Arranges A, B, and C in increasing order.)

so here's what I came up with

Library
(header file)
 
void increasing(double& A, double& B, double& C); //Arranges A, B, and C in increasing order. 


(source file)
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
#include <iostream>

using namespace std;

void increasing(double& A, double& B, double& C)
{
	double small, medium, large;
	if ((A <= B) && (A <= C) && (B <= C))
	{
		small = A;
		medium = B;
		large = C;
	}
	if ((A <= B) && (A <= C) && (B >= C))
	{
		small = A;
		medium = C;
		large = B;
	}
	if ((A <= B) && (A >= C) && (B <= C))
	{
		small = B;
		medium = A;
		large = C;
	}
	if ((A >= B) && (A <= C) && (B <= C))
	{
		small = B;
		medium = A;
		large = C;
	}
	if ((A >= B) && (A >= C) && (B <= C))
	{
		small = B;
		medium = C;
		large = A;
	}
	if ((A >= B) && (A <= C) && (B >= C))
	{
		small = C;
		medium = A;
		large = B;
	}
	if ((A >= B) && (A >= C) && (B >= C))
	{
		small = C;
		medium = B;
		large = A;
	}
	if ((A <= B) && (A >= C) && (B >= C))
	{
		small = A;
		medium = B;
		large = C;
	}
	if ((A <= B) && (A >= C) && (B >= C))
	{
		small = C;
		medium = A;
		large = B;
	}

	A = small;
	B = medium;
	C = large;
	return;
}


and then we're supposed to (Use the library in a program where the user is asked to enter three numbers. The program calls all three functions above and outputs the new values of A, B, and C for each case.)

so I made this
(program)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "ughh.h"
#include<iostream>
using namespace std;

void increasing(double& A, double& B, double& C);

int main()
{
	double A, B, C, please;
	cout << "Enter 3 numbers:";
	cin >> A >> B >> C;
	please = increasing(double& a, double& b, double& c);
	cout << "Arranged in increasing order:" << please << endl;
	system("pause");
	return 0;
}


now everything seems to be working alright except for an error in the line
 
	please = increasing(double& a, double& b, double& c);


any suggestions?
When calling the function you must not mention the parameter types. You also need to spell the variables correctly. C++ is case-sensitive so a is not the same variable name as A.

 
please = increasing(A, B, C);
Last edited on
You are not assigning anything to please.
Jack816, Am I not assigning the increasing(double& a, double& b, double& c); to please?
Last edited on
void means the function doesn't return a value. You can't assign the return value because there isn't any.
What value does the function increasing() return?

None.

Why would you assign that to a double variable? (It is not possible.)


Your function takes by reference arguments. Calling it with A, B and C modifies the A, B and C.


Is the "ughh.h" the header file that declares your increasing() ?
If yes, why do you declare the function again on line 5?
Topic archived. No new replies allowed.