C++ Program to Calculate Area and Perimeter of Circle2 min read

The circle’s circumference — the measure of the total length around the shape — is determined based on the fixed ratio of Pi. In degrees, a circle is equal to 360° and Pi (p) is the fixed ratio equal to 3.14.

Area: p * r * r

Perimeter: 2 * p * r

C++ Code:


This is a C++ program that calculates the area and perimeter of a circle, given the radius as input from the user.

The program starts by including the necessary libraries, iostream for input and output, stdlib.h for general purpose functions and cmath for mathematical functions.

In the main function, the program declares two double variables r, area, and perimeter.

It then uses cout to prompt the user to input the radius of the circle, and uses cin to accept the input value and store it in the variable r.

The program then calculates the area of the circle using the formula Area = PI * r^2, where PI is a predefined constant in cmath library. The same formula is used to calculate the perimeter of the circle which is 2PIr.

It then uses cout to display the area and perimeter of the circle, with the value of the area and perimeter being calculated from the previous step.

This program uses mathematical functions from the cmath library to calculate the area and perimeter of a circle, based on user input for the radius. It then displays the results to the user.

Leave a Comment