C++ program to find the area of a circle
In this C++ program tutorial our task is to:

Write a C++ program to find the area of the circle
C++ program to calculate the area of a circle
Given below is the C++ code where we take radius of the circle as an input and the area of the circle is given as the output.
#include<iostream>
#define pi 3.14 //macros where the value of pi is defined
using namespace std;
int main()
{
float radius,areaOfCircle;
cout<<"Enter the value of the radius"<<endl;
cin>>radius;
areaOfCircle = pi * radius * radius; //Calculating the area of the circle
cout<<"Area of the circle\n"<<areaOfCircle<<endl;
return 0;
}
OUTPUT :
Enter the value of the radius
2
Area of the circle
12.56
A macros is defined in the above program (#define pi 3.14). Macros are defined so that the program run faster and is very efficient while doing competitive programming.
EXPLANATION:

In the above program the compiler first compiling from the main function (here int main()).

Then two 4(assuming 32/64bit system) bits memory space are created for the two float variable .

Then it takes in the input for the radius and goes to the calculation part.

It then searches for the value of "pi" which has been defined as a macros.

After that the value get saved in the areaOfCircle
You can see the above code execution and output in codeblocks IDE:
Would you like to see your article here on tutorialsinhand.
Join
Write4Us program by tutorialsinhand.com
About the Author
Sayantan Bose
 š Iām currently working on DS Algo skills
 š± Iām currently learning web develeopement
 šÆ Iām looking to collaborate with Oppia
 š« Reach me at https://www.linkedin.com/in/sayantanbose14134a1a6/
 š Pronouns: his/him
Page Views :
Published Date :
Jul 24,2020