Answer to Question #200993 in C++ for Master j

Question #200993

Use the c++ programming language to write a computer program that implement and uses the following two user-defined functions:

i. getcircumference, which promps and accepts the value of a radius r its user, and then computes and returns the circumference for the circle.

ii. getArea, which accepts the value of a circle's circumference in it's parameters, and then computes and return the area of a circle


Your computer program just correctly use the functions to obtain the circumference and area of a circle, and then output the results.

Note: area of a circle = πr2

Circumference = 2πr


1
Expert's answer
2021-05-31T05:39:12-0400
#include <iostream>
using namespace std;
const float PI = 3.14159265359;
float getCircumference(){
    cout<<"Input the radius: ";
    float r; cin>>r;
    return 2 * PI * r;
}
float getArea(float circumference){
    float r = circumference / (2 * PI);
    return PI * r * r;
}
int main(){
    float circumference = getCircumference();
    cout<<"The circumference is "<<circumference<<endl;
    cout<<"The area is "<<getArea(circumference);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog