Search
  • Soumen(ADMIN)

Area of Shapes

Updated: Aug 26


#include<iostream>

using namespace std;


int circle(float x) {

float area=3.14*x*x;

cout<<"the area of the circle is "<<area<<endl;

}

int square(int x) {

int area=x*x;

cout<<"the area of the square is "<<area<<endl;

}

int triangle(float x,float y) {

float area=0.5*x*y;

cout<<"the area of the triangle is "<<area<<endl;

}

int main() {

int r;

float i,j,k;

cout<<"please enter 1 or 2 or 3 to calculate the area"<<endl<<"1.Circle"<<endl<<"2.Square"<<endl<<"3.Triangle"<<endl;

cin>>r;

if(r==1) {

cout<<"Enter the radius of Circle : ";

cin>>i;

circle(i);

}

else if(r==2) {

cout<<"Enter the side value of square : ";

cin>>i;

square(i);

}

else if(r==3) {

cout<<"Enter the height and base of Triangle : ";

cin>>j>>k;

triangle(j,k);

}

else {

cout<<"You have choose wrong option!!!!"<<endl;

}

}


please enter 1 or 2 or 3 to calculate the area

1.Circle

2.Square

3.Triangle

1

Enter the radius of Circle : 5

the area of the circle is 78.5


--------------------------------

82 views
  • Facebook Social Icon

©2019 by WEBTONEXT