Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop a function that calculates and returns the surface area and the volume o

ID: 3690258 • Letter: D

Question

Develop a function that calculates and returns the surface area and the volume of a sphere. Both the values calculated must be returned through the reference variables that are passed as arguments. The radius of the sphere must also be passed as an argument by value. Test this function in a main program. The main program must ask the user to enter the radius of the sphere and print the values of area and value returned by the function Formulas: Area = 4 pi r 2 and Volume = (4pi r3)/3; Where r is the radius and pi = 3.14286

Explanation / Answer

#include<iostream>

using namespace std;

void areavolume(float *a,float *v,int r)

{

*a= 4*3.14*r*r;

*v=1.33* 3.14*r*r*r;

}

int main()

{

int r;

float *area,*volume;

cin>>r;

areavolume(area,volume,r);

cout<<"area is "<<*area;

cout<<"volume is "<<*volume;

}

Thanks