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.

Continue your learning journey with a 14-day free trial.

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