Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

7.) (7) Write a value-returning function to calculate the area of a right triang

ID: 3602339 • Letter: 7

Question

7.) (7) Write a value-returning function to calculate the area of a right triangle, given the base and height. Area = 1/2bh. Showa samplecallin ma in to this function 8.) (7) Write a value-returning function to calculate the perimeter of a right triangle given the base and height. Perimeter-b + h + hypotenuse. Hypotenuse = sqrt(b2 + 9.) (7) Write a void method to calculate the area and perimeter of a right triangle and return both answers to main by reference. Show a sample call in main to this function,

Explanation / Answer

#include<iostream>
using namespace std;

// Question(7) it is the method that takes 2 integers that are base and height
double area(int base, int height)
{
// returing 1/2.b.h
return (base*height/2);
}

main()
{
// calling function and printing returned output
cout << area(4, 5);
}

/*
SAMPLE output
10
*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote