using only CODE BLOCKS software C++ , please do the lab project bellow: // Lab P
ID: 3666673 • Letter: U
Question
using only CODE BLOCKS software C++ , please do the lab project bellow:
// Lab Project 2 // Enter your name: #include #include #include using namespace std; // complete the following three functions // The function InputBaseHeight will read the values for the Base and Height of a Triangle from the keyboard // and pass the Base and Height values back through a reference parameter. void InputBaseHeight( ) // The function TriangleArea will receive the Base and Height values through a value parameter and // return the Area of the Triangle through the function name double TriangleArea ( // Area = 1/2 * Base * Height // The function PrintArea will receive the Area value through a value parameter // and label and print the Area value. void PrintArea ( int main() { double Base = 0.0, height = 0.0, Area = 0.0; // call InputBaseHeight function InputBaseHeight( ) // call TriangleArea function // call PrintArea return 0; } void InputBaseHeight( )
Explanation / Answer
#include<iostream.h>
#include<conio.h>
using namespace std;
void inputBaseHeight();
double triangleArea(double,double);
void printArea(double);
int main()
{
double base=0.0;
double height=0.0;
double area=0.0;
cout<<"please input the base and height of the triangle";
inputBaseHeight(&base, &height);
cout<<"you have entered base="<<base;
cout<<"you have entered height ="<<height;
&area= triangleArea(&base, &height);
printArea(&area);
}
void inputBaseHeight(double *ptrB,double *ptrH)
{
cin>>*prtB;
cin>>*ptrH;
}
double triangleArea(double *ptrB, double *ptrH)
{
*ptrA= (1/2) * (*ptrB) * (*ptrH);
return *ptrA;
}
void printArea(double *ptrA)
{
cout<<"the area of triangle is:"<<*ptrA;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.