Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions