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.
#define pi 3.14 //macros where the value of pi is defined
using namespace std;
cout<<"Enter the value of the radius"<<endl;
areaOfCircle = pi * radius * radius; //Calculating the area of the circle
cout<<"Area of the circle\n"<<areaOfCircle<<endl;
Enter the value of the radius
Area of the circle
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.
In the above program the compiler first compiling from the main function (here int main()).
Then two 4(assuming 32/64-bit 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.
program by tutorialsinhand.com
About the Author
- 🔭 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/sayantan-bose-14134a1a6/
- 😄 Pronouns: his/him
Page Views :
Published Date :