Example 54: Area and Perimeter

Learn how to calculate the area and perimeter of a circle, square and triangle using macro definitions.

We'll cover the following

Problem

Write macro definitions with arguments for calculation of the area and perimeter of a triangle, square, and circle.

Store these macro definitions in a file called areaperi.h. Include this file in your program, and call the macro definitions for calculating the area and perimeter for a square, triangle, and circle.

Solution

Given below is our recommended way to approach this problem.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.