Navigation Bar

Program Circle Class to calculate circumference and display Maximum Circumference



#include<iostream>
using namespace std;
class circle
{
                private :
                                float radius;
                public:
                void setrad(float r1)
                {
                                radius = r1;
                }
                float getarea()
                {
                                return (3.14 * radius * radius);
                }
                void circum()
                {
                                cout<<"\nCircumfrence = "<<2 * 3.14 * radius<<endl;
                }
};
int main()
                {
                circle c,c1;
                float r1,r2;
                cout<<"Enter Radius: ";
                cin>>r1;
                c.setrad(r1);
                c.circum();
                cout<<"\nEnter 2nd Radius: ";
                cin>>r2;
                c1.setrad(r2);
                c1.circum();
                cout<<"\nMax Circumfrence";
                if(c.getarea()>c1.getarea())
                                c.circum();
                else
                                c1.circum();
               

Output

No comments:

Post a Comment