**LEVEL:** Beginner

Whats in this post?

- Code
- Output
- Background and Explanation of the code

**Code**

To copy code: Click “View Source” on the right of this code snippet.

** Background and Explanation of the code**

This is a simple program which calculates the **area** of the different **shapes** like circle,rectangle,square and triangle by calling different functions/procedures. In this program, firstly the constant pi=3.14 and other variables are defined. Then the program calculates the area of circle. Here, two different functions have been defined for input and output. Output calculates the area of circle using the formula area=rad*rad*pie . After this, the program calls another subroutines which takes two different inputs from user – length and width and calculate the area of rectangle and square and shows it to user. The area of rectangle is calculated using the formula area=length*width. There are also three different function calls for triangle. One calculates sum and print area of triangle. The second checks whether the sum of two sides of triangle is not greater than the third side. The third function calculates the area of triangle using the sqrt function of MATH library.