can someone help with this please!!!

//Note: This program should include three functions, which
// you must write the declarations and definitions of.
// You must decide which functions return a value and
// which are simply void. Observe how the functions
// are used in 'main' for a HINT. In addition, edit
// the main function to include a validity check on
// inputs by user (check that values are between 1-10).

#include<iostream>
#include<cmath>
using namespace std;

//--------------Input your function delcarations here!---------------
int getSum(int num1,int num2,int num3);

void squares(int num1,int num2,int num3);

void product(int num1,int num2,int num3);
//----
int main()
{
int num1, num2, num3, sum;
cout<<"Please enter three integer values between 1-10: ";
cin>>num1>>num2>>num3;

//Calculate and display sum
sum = getSum(num1, num2, num3);
cout<<"The sum of the set is "<<sum<<"."<<endl;

//Calculate and display sum of squares
squares(num1, num2, num3);

//Calculate and display product
product(num1, num2, num3);

return 0;

}

//--------------Input your function definitions here!---------------

int getSum(int num1,int num2,int num3)
{
cout<<"the sum is"<<endl;
return(num1+num2=num3);
}

void squares (int num1,int num2,int num3)
{
using namespace std;
squares=((pow(num1,2))+ (pow(num2,2))+( pow(num3,2)));
cout<<"sum of all squares is"<<squares<<endl;
return;
}

void product(int num1,int num2,int num3)
{
product=num1*num2*num3;
cout<<"the product of all numbers"<<product<<endl;
return;
}
//----------------------END function definitions--------------------




1
2
return(num1+num2=num3);
                ^
Last edited on
these are my errors though,,,


usingFunctionsA.cpp:67: warning: the address of `void squares(int, int, int)',
will always be `true'
usingFunctionsA.cpp: In function `void product(int, int, int)':
usingFunctionsA.cpp:73: assignment of function `void product(int, int, int)'
usingFunctionsA.cpp:73: cannot convert `int' to `void ()(int, int, int)' in
assignment
usingFunctionsA.cpp:74: warning: the address of `void product(int, int, int)',
will always be `true'
i fixed that and have the same errors
In function product(int num1,int num2,int num3) you should declare local variable, for an example:
int product=num1*num2*num3;. But, I don't think it is a good idea to use function name as a local variable. Introduce some other name.

In function square is something similar.
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
#include<iostream>
#include<cmath>
using namespace std;

//--------------Input your function delcarations here!---------------
int getSum(int num1,int num2,int num3);
int squares(int num1,int num2,int num3);
int product(int num1,int num2,int num3);
//----
int main()
{
		int num1, num2, num3, sum;
		cout<<"Please enter three integer values between 1-10: ";
		cin>>num1>>num2>>num3;

		//Calculate and display sum
		sum = getSum(num1, num2, num3);
		cout<<"The sum of the set is "<<sum<<"."<<endl;

		//Calculate and display sum of squares
		cout<< "\n Square"<<squares(num1, num2, num3);

		//Calculate and display product
		cout<< "\n Peoducts"<<product(num1, num2, num3);

		return 0;

}

//--------------Input your function definitions here!---------------

int getSum(int num1,int num2,int num3)
{
	
	return (num1+num2);
}

int squares (int num1,int num2,int num3)
{
		squares=((pow(num1,2))+ (pow(num2,2))+( pow(num3,2)));		
		return squares;
}

int product(int num1,int num2,int num3)
{
	product=num1*num2*num3;
	cout<<"the product of all numbers"<<product<<endl;
	return product;
}
//----------------------END function definitions--------------------

Last edited on
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
//Note: This program should include three functions, which
// you must write the declarations and definitions of.
// You must decide which functions return a value and
// which are simply void. Observe how the functions
// are used in 'main' for a HINT. In addition, edit
// the main function to include a validity check on
// inputs by user (check that values are between 1-10).

#include<iostream>
#include <cstdlib>

using namespace std;

//--------------Input your function delcarations here!---------------
int getSum(int,int,int);

void squares(int,int,int);

void product(int,int,int);
//----
int main()
{
int num1, num2, num3, sum;
cout<<"Please enter three integer values between 1-10: ";
cin>>num1>>num2>>num3;

//Calculate and display sum
sum = getSum(num1, num2, num3);
cout<<"The sum of the set is "<<sum<<"."<<endl;

//Calculate and display sum of squares
squares(num1, num2, num3);

//Calculate and display product
product(num1, num2, num3);

return 0;

}

//--------------Input your function definitions here!---------------

int getSum(int num1,int num2,int num3)
{
return(num1+num2+num3);
}

void squares (int num1,int num2,int num3)
{
int powers=(num1*num1)+(num2*num2)+(num3*num3);
cout<<"sum of all squares is"<<powers<<endl;
}

void product(int num1,int num2,int num3)
{
int mul=num1*num2*num3;
cout<<"the product of all numbers"<<mul<<endl;
}
//----------------------END function definitions-------------------- 
Last edited on
Topic archived. No new replies allowed.