Answer to Question #180402 in C++ for alizeyh

Question #180402

Write a program that gets a choice from user if choice is ‘R’ program should calculate area of a rectangle and display it, if the choice is ‘T’ then it shall calculate area of circle and display it.



1
Expert's answer
2021-04-12T01:05:14-0400
#include <bits/stdc++.h>
using namespace std;


int main()
{
    int length,breadth,radius,area_rect,area_circle;
    string choice;
    cout<<"Enter your choice: ";
    cin>>choice;
    
    if (choice == "R")
    {
        cout<<"Enter the length of rectangle:";
        cin>>length;
        
        cout<<"Enter the breadth of rectangle:";
        cin>>breadth;
        
        area_rect = length * breadth;
        
        cout<<"Area of Rectangle: "<<area_rect;
    }
    else if (choice == "T")
    {
        cout<<"Enter radius of circle: ";
        cin>>radius;
        
        area_circle = 3.14 * radius * radius;
        
        cout<<"Area of Circle:"<<area_circle;
    }


    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