This is a very basic problem, I need to find the area and volume of a sphere but I am getting this error:
error C2065: 'v' : undeclared identifier
error C2065: 'a' : undeclared identifier
Here is my program:
#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;
}
the question says that The function should not perform any I/O operations. so how can I show the results ??