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

C++ help Complete the following function that takes 3 arguments of a circle : -

ID: 3805982 • Letter: C

Question

C++ help

Complete the following function that takes 3 arguments of a circle :

-       radius (input argument)

-       area (output argument, to be calculated)

-       circumference (output argument, to be calculated)

All arguments are double type.

If a radius is negative, the function returns false, otherwise it returns true.

The function does only calculation, and does nothing else.

Assume that all #include are already there   

// Fill in your Function prototype

bool circleAreaAndCircumference ( _______, ________, __________);

int main() {

   double radius, area, circumference;

   cout << "Enter a circle radius:";

   cin >> radius;

   bool res =____________________

   if (res)

            cout << "Area is " << area << endl << "Circumference is " << circumference << endl;             

   else

           cout << "Invalid circle";

}

// Fill in your function definition

................

Explanation / Answer

//Here one more change, in question it was given bool instead it should be boolean type.

boolean circleAreaAndCircumference (double radius, double &area, double &circumference);

int main() {
double radius, area, circumference;
cout << "Enter a circle radius:";
cin >> radius;
boolean res = circleAreaAndCircumference(radius, area, circumference);
if (res)
cout << "Area is " << area << endl << "Circumference is " << circumference << endl;   
else
cout << "Invalid circle";
}

boolean circleAreaAndCircumference (double radius, double &area, double &circumference)
{
if(radius<0)
{
return false;
}
else{
area = 3.14 * r * r; //calculating area
circumference = 2*3.14*r; //calculating circumference
return true;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote