Whats in this post?
- Background and Explanation of the code
To copy code: Click “View Source” on the right of this code snippet.
Background and Explanation of the code
The above program is used to calculate the area and circumference of a circle for a given radius r.The class circle contains a private data member r and three public member functions : input ( ) , area ( ) and circumference ( ) which are declared inside the class and defined outside.In the main ( ) , the statement circle c1; informs the compiler that c1(object) is a variable of type circle which is user defined data type.The public member functions are called from main ( ) through the object c1 to generate the required output.
Enter radius of circle = 4
Area of circle = 50.26
Circumference of circle = 25.13