0

Sum and Average in functions. It compiled but the result is showing garbage value. could anyone write the proper form of code an

#include<iostream> using namespace std; int sum (int,int); int average (int, int); int main () { int num1; int num2; cout<<"\nEnter first Value:"; cin>> num1; cout<<"\nEnter second Value:"; cin>> num2; sum (num1,num2); average (num1,num2); cout<<"\nThe sum is:" << " " << sum; cout<<"\nThe average is:" << " " << average; return 0; } int sum ( int a, int b) { return (a + b); } int average (int a, int b) { return (sum (a,b)/2); }

29th Nov 2019, 3:59 PM
Dipanjan Basu
Dipanjan Basu - avatar
3 odpowiedzi
+ 1
29th Nov 2019, 4:18 PM
Avinesh
Avinesh - avatar
0
average should return double (or other type of decimal I dont really know C++)
29th Nov 2019, 4:01 PM
Trigger
Trigger - avatar
0
And you have to store the values you return from your functions
29th Nov 2019, 4:02 PM
Trigger
Trigger - avatar