Program to Calculate Area of Circle, a Rectangle or a Square
Tuesday, August 11, 2020
//Program to Calculate Area of Circle, a Rectangle or a Square
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{clrscr();
int r,L,B,s;
int ch;
float area;
cout<<"\n press 1 for circle";
cout<<"\n press 2 for rectangle";
cout<<"\n press 3 for square";
cout<<"\n enter your choice :";
cin>>ch;
switch(ch)
{case 1:cout<<"\n enter the radius:";
area=3.14*r*r;
cout<<"\n"<<"the area of the circle is"<<area<<"\n";
break;
case 2:cout<<"\n enter length and breadth of rectangle:";
cin>>L>>B;
area=L*B;
cout<<"\n"<<"the area of rectangle is"<<area<<"\n";
break;
case 3:cout<<"\n enter the sides of square:";
cin>>s;
area=(s*s);
cout<<"\n"<<"the area of the square is"<<area<<"\n";
break;
default:cout<<"\n wrong choice entered";
}
getch();
}
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{clrscr();
int r,L,B,s;
int ch;
float area;
cout<<"\n press 1 for circle";
cout<<"\n press 2 for rectangle";
cout<<"\n press 3 for square";
cout<<"\n enter your choice :";
cin>>ch;
switch(ch)
{case 1:cout<<"\n enter the radius:";
area=3.14*r*r;
cout<<"\n"<<"the area of the circle is"<<area<<"\n";
break;
case 2:cout<<"\n enter length and breadth of rectangle:";
cin>>L>>B;
area=L*B;
cout<<"\n"<<"the area of rectangle is"<<area<<"\n";
break;
case 3:cout<<"\n enter the sides of square:";
cin>>s;
area=(s*s);
cout<<"\n"<<"the area of the square is"<<area<<"\n";
break;
default:cout<<"\n wrong choice entered";
}
getch();
}
0 Comments