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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started