I am trying to solve this question (homework) that says the following :
Write a program that calls a function computeSphere that computes the volume and the surface area of a sphere with given radius. The function should not perform any I/O operations.
the main problem is how can I let my function (computeSphere) return 2 variables to main function ??
this is my code :
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int r;
int computeSphere(int r)
{
double a,v;
a = 4*3.14* pow(r,2);
v = (4/3) * 3.14 * pow(r,3);
return a,v;
}
int main()
{
cout << "Enter the radius: ";
cin >> r;
cout << fixed << setprecision(2);
computeSphere(r);
cout << "The area of a sphere of radius " << r << " is " << a << " and its ";
cout << "volume is ";
cout << v;
cout << endl;
return 0;
}
It gives me 2 errors while compiling :
error C2065: 'a' : undeclared identifier
error C2065: 'v' : undeclared identifier
any help is appreciated :).