Function with one return value Write a C function that retur
Function with one return value: Write a C++ function that returns volume of a sphere in cubic meters given he radius in meters. Write a main program that calls the function within a loop in order to print the radius and volume in a table as the radius varies from 1 m to 10 m. The table might appear as shown below:
Solution
#include<iostream>
using namespace std;
int main()
{
cout<<\". Radius(m)\\tVolume(m^3)\";
for(int i=1;i<=10;i++)
{
cout<<\"\ . \"<<i<<\"\\t\"<<vol(i);
}
return 0;
}
double vol(int r)
{
double a=double(r);
return (4/3)*3.14*a*a*a;
}
