Extend the “Circle” class to have the following features.
In the main program, create two objects of classCircle. Find which of the two circles is smaller (by comparing their radii) and enlarge the smaller circle by a factor of 2.
Code:
#includeusing namespace std;//Class which holds properties and methods of a classclass Circle {private: int radius;public: //Parameterized constructor that creates an object Circle(int r=0) {radius=r;} //Member function to find area int area(){ return 22*radius*radius/7; } //Member function to find circumference int circumference(){ return 2*22*radius/7; } //Member function to print results void print(int ar, int cf) { cout<"area of="" circle="" with="" radius="">"area><><" is="">"><><" and="" circumference="" of="" circle="" is="">"><><> }};int main(){ Circle c1(49),c2(61); //Creating two objects of class circle int ar1=c1.area(); int cf1=c1.circumference(); c1.print(ar1,cf1); int ar2=c2.area(); int cf2=c2.circumference(); c2.print(ar2,cf2); return 0;}
//Class which holds properties and methods of a classclass Circle {private: int radius;public:
//Parameterized constructor that creates an object Circle(int r=0) {radius=r;}
//Member function to find area int area(){ return 22*radius*radius/7; }
//Member function to find circumference int circumference(){ return 2*22*radius/7; }
//Member function to print results void print(int ar, int cf) { cout<"area of="" circle="" with="" radius="">"area><><" is="">"><><" and="" circumference="" of="" circle="" is="">"><><> }};int main(){ Circle c1(49),c2(61); //Creating two objects of class circle int ar1=c1.area(); int cf1=c1.circumference(); c1.print(ar1,cf1); int ar2=c2.area(); int cf2=c2.circumference(); c2.print(ar2,cf2); return 0;}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here