help with paramter functions

so my teacher wants me to create another function for this called "sumit" the function will take three doubles and return the sum of the three doubles. what im i doing wrong? i keep getting build errors. god i didnt know c plus was going to be this hard!!! its soo much dang math!
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
  Put the c#include <iostream>

using namespace std;

int getValue();
int cubeit(int x);



int main()
{
	double x = 3.3;
	double y = 2.1;
	int z = 5;
	int sum;
	int num;
	num = getValue();
	int cube = cubeit(num);
	cout << "the cube of your value is " << cube << endl;
	
	cout << " the sum of your values is" << sum << endl;
	sum = sumit(x, y, z);


	return 0;
}
int getValue()
{
	int val;
	cout << "enter a number" << endl;
	cin >> val;
	return val;
}
int cubeit(int x)
{
	return x * x * x;
}
int product(int a, int b)
{
	return a * b;
}
int sumit(double a, double b, int c)
{
	return static_cast<int>(a) + static_cast<int>(b) + c;
}ode you need help with here.
You need to declare the function before you can use it, like you have done with the other functions.

1
2
3
int getValue();
int cubeit(int x);
int sumit(double a, double b, int c);


After you have done this the code should compile but you said the function should take three doubles as arguments, and I assume the function is supposed to return a double as well, so the function would look more like this.

1
2
3
4
double sumit(double a, double b, double c)
{
	return a + b + c;
}


You might want to consider using double everywhere in your program.
Last edited on
Topic archived. No new replies allowed.