1 /* C++ How to Program, 9/E, by Paul Deitel & Harvey Deitel.
3 Solution of exercise 2.20:
4 (Diameter, Circumference and Area of a Circle) Write a program that reads in
5 the radius of a circle as an integer and prints the circle's diameter,
6 circumference and area. Use the constant value 3.14159 for π. Do all
7 calculations in output statements. [Note: In this chapter, we’ve discussed
8 only integer constants and variables. In Chapter 4 we discuss floating-point
9 numbers, i.e., values that can have decimal points.]
11 Written by Juan Carlos Moreno (jcmhsoftware@gmail.com), 2022/01/02 */
21 cout
<< "Enter radius of the circle: ";
24 cout
<< "Diameter of the circle is " << 2*radius
<< endl
; //D = 2r
25 cout
<< "Circumference of the circle is " << 2*3.14159*radius
//C = 2πr
27 cout
<< "Area of the circle is " << 3.14159*radius
*radius
//A = πr^2