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!
Put the c#include <iostream>
usingnamespace 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)
{
returnstatic_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.