Answer to Question #155832 in C++ for mahikah

Question #155832

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



1
Expert's answer
2021-01-16T11:48:21-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS