📄 area.cpp
字号:
#include<iostream.h>
#include<conio.h>
class shape
{
float ar,per;
public:
void area(double s)
{
ar=s*s;
per=4*s;
cout<<"area of square is:"<<ar;
cout<<"\nperimeter of square is:"<<per;
}
void area(float r)
{
ar=3.14*r*r;
per=2*3.14*r;
cout<<"area of cicle is:\n"<<ar;
cout<<"\nperimeter of circle is:"<<per;
}
void area(float a,float b)
{
ar=a*b;
per=2*(a+b);
cout<<"Area of rectangle is:\n"<<ar;
cout<<"\nPerimeter of rectangle is:"<<per;
}
void area(int l)
{
ar=6*l*l;
per=l*l*l;
cout<<"Area of cube is:\n"<<ar;
cout<<"\nPerimeter of cube is:\t"<<per;
}
};
void main()
{
shape x;
clrscr();
char ch1;
double s;
int l,ch;
float r,a,b;
do
{
cout<<"1.square"<<endl<<"\n2.circle"<<endl<<" \n3.rectangle"<<endl<<"\n4.cube";
cout<<"\nenter ur choice";
cin>>ch;
switch(ch)
{
case 1:
cout<<"enter side of square";
cin>>s;
x.area(s);
break;
case 2:
cout<<"enter radius of circle:";
cin>>r;
x.area(r);
break;
case 3:
cout<<"Enter lenght and breadth of rectangle:";
cin>>l>>b;
x.area(l,b);
break;
case 4:
cout<<"Enter side of cube:";
cin>>l;
x.area(l);
break;
}
cout<<"\ndo u want to cont";
cin>>ch1;
}while(ch1=='y');
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -