Calling functions

So I get 3 errors when the following code is run, errors i really don't know how such a thing can happen. They are 3 of the same error:

1>c:\users\jad\desktop\program 2.cpp(47) : error C2664: 'level' : cannot convert parameter 1 from 'double *' to 'double'

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
 #include <iostream>

using namespace std;

double level(double a, double b)
{
	if (a>b)
	{
		a=a/2;
		return a,b;
	}
	if (a<b)
	{
		b=b/2;
		return a,b;
	}
	if (a=b)
	{
		a=a/2;
		b=b/2;
		return a,b;
	}
}

void main()
{
	double a;
	double b;
	double c;
	double d;

	a=100;
	b=200;
	c=400;
	d=800;
	
	cout<<"Enter 4 numbers: ";
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;

	double level (double,double);
	
	for (int i=0;i<10;i++)
	{
		cout<<	level(&a,  level(&b,  level(&c,&d)));
		cout<<" ";
	}
	
	char r;
	cin>>r;
}
Exactly what am I doing wrong here?
Line 17 - don't use assignment (=), test equality (==).

Line 10, 15, 21; A function can only return one value. The , operator isn't doing what you think it's doing, you shouldn't be trying to return more than 1 value.

Line 43 - Maybe you know this, but you should realize that this is a being seen by the compiler as just a function prototype. Line 43 doesn't run your function.

Line 47, why are you passing in the addresses of a b and c?
If you meant to use C++ references, you need to format your level function to be
double level(double& a, double& b)

Also, main should be return int, not be void.
Last edited on
Well the errors are gone, however the program isn't working as it should be, thank you for answering my question anyways
Topic archived. No new replies allowed.