NAME: STUDENT ID ENGR3200 PROGRAMMING PROBLEM 2: S+5+5+5 points) Using the four-
ID: 2249420 • Letter: N
Question
NAME: STUDENT ID ENGR3200 PROGRAMMING PROBLEM 2: S+5+5+5 points) Using the four-step development method, write a function that calculates the area, a, of cakculated value of radi You may use "asin and "pow functions from the ccmath> library. "double area (double, double&) a circle when its circumference, c, is given and it additionally returns the us, r. The relevant formulas are r-c/(2) and -m2, where = 2 san-1 1. Write a Cr+ program that accepts the value of the circumference from the user, calculates the radius and ares, and displays the calculated values. Your program must instantiate the function "double area (double, doubles)" (Input data validation and/or additional test cases will lead to BONUS CREDITS). HINT: Your function instantiation in the "int main ( )-will look like: a area (c, r} ; SOLUTION: STEP 1: Analyze the Problem - From the specified function prototype double doublos), we find one double input( area (double, ) and two double outputs( STEP 2: Develop a Solution- Input Data Validation (Bonus Credit 2) Hand Calculations, Test Cases: 11/7/2017 GHSCSE- FDUExplanation / Answer
Answer:- The code for doing so, can written as-
#include<iostream>
#include<cmath>
using namespace std;
double area(double, double &);
int main()
{
double a, c, r;
cout<<" Enter the value of circumference of circle: ";
cin>>c;
a = area(c, r);
cout<<" Area of Circle : "<<a;
cout<<" Radius of Circle : "<<r;
return 0;
}
double area(double c, double &r)
{
double pi, a;
pi = 2*asin(1);
r = c/(2*pi);
a = pi*r*r;
return a;
}
OUTPUT:-
Enter the value of circumference of circle: 6.29
Area of Circle : 3.14841 Radius of Circle : 1.00108
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.