Question: Use C++ Computing the Area of a Triangle Using the algorithm that computes the area of a triangle from the lecture, write the code to

Use C++

Computing the Area of a Triangle

Using the algorithm that computes the area of a triangle from the lecture, write the code to do the following:

1. Prompt the User for the base and the height of a triangle 2. Calculate the area of the triangle. 3. Print out the area.

You will need to:

  • Make the value of 2 a constant.
  • Use the following Formula: A = bh

1. Create a new source file in Dev C++ and name it YourLastNameLab3. Enter the Compiler Directives:

/************************** Compiler Directives **********************/

#include

#include

#include using namespace std;

2. Enter Code in the main.cpp form.

First, enter the main function header:

/**************************** main Function **************************/

int main()

{ //dont forget to start main with a curly bracket

3. Then enter the local variables from your input and output chart in your Prologue.

4. Use the Refined Algorithm as your step by step guide and enter each line of code.

5. Add code to pause output screen and terminate program: //Pause to read output system ("pause"); //Indicate to OS successful termination of program return 0; } //dont forget to end main with a curly bracket

5. Save and Run the program. Test it for several different base and height values.

NOTE: 1. Declare all variables within the data declaration section. 2 Do not get input on the same line as a variable declaration. 3. Do not place an equation for computation on the same line as declaring a variable.

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!