Write a program that defines the named constant PI, const double PI = 3.1419; which stores the value of p. The program should use PI and some of the math functions you learn previously to accomplish the tasks. In the main program, prompt the user to input the value of a double variable r, which stores the radius of a circle. The program then call the following functions and output the appropriate results.
(a) The value of πr2, which is the area of the circle.
(b) The value of 2πr which is the circumference of the circle.
1
Expert's answer
2012-07-12T08:26:14-0400
# include<iostream.h> # include<conio.h>
double pi = 3.1419, r;
double area(double r){ return pi*r*r; }
double circumference(double r){ return 2*pi*r; }
void main(){ cout<<"Enter the radius of a circle: "; cin>>r; cout<<"The area of a circle is "<<area(r)<<"\r\n"; cout<<"The circumference of a circle is "<<circumference(r)<<"\r\n"; getch(); }
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment