Exercise 1: Calculating Area

Let's calculate the area of a triangle by using Classes.

Problem Statement

In this exercise, you have to write a class Triangle that contains two public float data members, length and height, a public constructor that initializes these data members to 0 and a public member function area that calculates the area of the triangle and returns it.

Sample input

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy