In form of procedural programming, create a program that computes the area of a given rectangle and circle.
Area of rectangle = length * width
Area of circle = 3.1416 * radius
#include <iostream>
using namespace std;
int main()
{
string choice;
cout<<"Select option:\n";
cout<<"1: Area,Circle\n";
cout<<"2: Area, Rectangle\n";
cin>>choice;
if(choice=="1"){
int radius;
cout<<"Enter the radius: ";
cin>>radius;
int area = 3.1416*radius*radius;
cout<<"The Area of the Circle is "<<area;
}
else if(choice=="2"){
int length,width;
cout<<"Enter the length: ";
cin>>length;
cout<<"Enter the width: ";
cin>>width;
int area = length*width;
cout<<"The area of the Rectangle is "<<area;
}
else{
cout<<"Invalid input";
}
return 0;
}
Comments
Leave a comment