Question: Primarily using DEV C++ application for C++ coding. 2 different question. 2 different code. 1. Write a C++ program to calculate the area of a

Primarily using DEV C++ application for C++ coding.

2 different question. 2 different code.

1. Write a C++ program to calculate the area of a rectangle. [3mark] Sample Output:

Enter the length of a rectangle: 4

Enter the width of a rectangle: 6

Area of the rectangle is 24.

2. Write a C++ program to choose between the shape triangle and rectangle and then calculate the area. [6mark]

  • User will input two numbers regardless of the choice.
  • The user will then input the choice for the shape (R for rectangle, and T for triangle).
  • Utilize Functions.
  • Implement a condition to prompt user again in case of invalid input.
  • Area value should accommodate for fractional value. (Hint: Area of rectangle = L x B; Area of triangle = x B x H)

Enter the first parameter (length of a rectangle, or base of a triangle): 5

Enter the second parameter(height of a rectangle/triangle): 8

Select shape (R for rectangle, and T for triangle): C

Invalid choice. Select shape (R for rectangle, and T for triangle): T

Area of the triangle is 20.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!