Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

#include<iostream>

#include<cmath>

using namespace std;

int main()

float r,l,w,b,h,area;

int ch;

cout<<"1.Area Of Circle"<<endl;

cout<<"2.Area Of Rectangle"<<endl;

cout<<"3.Area Of Triangle"<<endl;

cout<<"Enter Your Choice :";

cin>>ch;

switch(ch)

case 1:

cout<<"Enter Radius Of The Circle: ";

cin>>r;

area=3.14*pow(r,2);

break;

case 2:

cout<<"Enter Length of the rectangle:";

cin>>l;

cout<<"Enter the width of the rectangle:";

cin>>w;

area=l*w;

break;
}

case 3:

cout<<"Enter the base of the triangle:";

cin>>b;

cout<<"Enter the height of the triangle:";

cin>>h;

area=(b*h)/2;

break;

default: cout<<"Invalid Input!";

break;

cout<<"Area = "<<area<<endl;

return 0;

#include<iostream>

#include<cmath>

using namespace std;

void Menu(int ch)

cout<<"1.Area Of Circle"<<endl;

cout<<"2.Area Of Rectangle"<<endl;
cout<<"3.Area Of Triangle"<<endl;

cout<<"Enter your choice:";

cin>>ch;

void ComputeArea(float r,float l, float w, float b, float h, float area)

int ch;

switch(ch)

case 1:

cout<<"Enter Radius Of The Circle: ";

cin>>r;

area=3.14*pow(r,2);

break;

case 2:

cout<<"Enter Length of the rectangle:";

cin>>l;

cout<<"Enter the width of the rectangle:";

cin>>w;

area=l*w;

break;

case 3:
{

cout<<"Enter the base of the triangle:";

cin>>b;

cout<<"Enter the height of the triangle:";

cin>>h;

area=(b*h)/2;

break;

default: cout<<"Invalid Input!"<<endl;

break;

cout<<"Area = "<<area<<endl;

void Choice(int )

int main()

float r,l,w,b,h,area;

int choice;

Menu(choice);

ComputeArea(r,l,w,b,h,area);

return 0;

You might also like