World Languages, asked by vasuclashofclans, 10 months ago

Write a function called tri_area that returns the area of a triangle with base b and height h, where b and h are input arguments of the function in
that order.​

Answers

Answered by raghavan21
9

Answer:

function [area, tri_area]= tri_area (b, h)

   

   area=(1/2)*(b)*(h)

   vca = area(:);

   tri_area = sum(vca);

end

Explanation:

Answered by poojan
3

Language using : Python Programming.

Area of triangle :   \frac{1}{2} * base * height

Program :

def tri_area(b,h):

   return( (1/2)*b*h )    

   # Or you can simply place this computation in avariable and return it.

#As the base and height can't always be an integer, let us take float values.

b=float(input("Enter the base of the triangle : "))

h=float(input("Enter the height of the triangle : "))

print("Area of the triangle is : ", tri_area(b,h), " Square units.")

Input 1 :

Enter the base of the triangle : 20

Enter the height of the triangle : 30

Output 1 :

Area of the triangle is :  300.0  Square units.

Input 2 :

Enter the base of the triangle : 91.64

Enter the height of the triangle : 72.83

Output 2 :

Area of the triangle is :  3337.0706  Square units.

Explanation :

  • First take two values (base, height) into two variables from user as an input.

  • Write a function using def keyword. The function need to send the area by calculating based on the base and height parameters sent during the function call.

  • You can directly make the computation happen in written statement, or you can compute it in the function ad store the resultant value into a variable, return that variable that has the value.

  • Make a function call with the needed parameters so that the function performs action and sends you the result.

Learn more :

1. Program to perform Arithmetic operations using function.

https://brainly.in/question/18905944

2. Write a simple python function to increase the value of any number by a constant "C=5"

https://brainly.in/question/16322662

Attachments:
Similar questions