Area of Circle Example C++ Program in C++
On this page (7sections)
About this program
This is an example program in c common example program. Read the concept first: C++ Variables and Data Types, then study the code and output below.
Definition
The area of a circle is π (Pi) times the Radius squared, which is written A=πr2.
Formula
The area of a circle is written
A=πr2
here,
r = Radius
π = ~3.14
Area Of Circle Example Program
/*##Area Of Circle In C++*/
/*##Calculation C++ Programs, Datatype C++ Programs, Basic C++ Programs*/
#include <iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int main(){
// Declare Variables
float radius, area;
cout << "Simple C++ Program : Area Of Circle\n";
cout <<"\nEnter the radius of Circle : ";
cin>>radius;
area = 3.14 * radius * radius;
cout <<"\nArea of Circle : "<<area;
getch();
return (0);
}
Sample Output
Simple C++ Program : Area Of Circle
Enter the radius of Circle: 2.0
Area of Circle:12.57
Related Pages
Learn the concept first, then study the code:
- C++ Programs — Browse all C++ Programs.
- C++ Variables and Data Types — Tutorial — data types and variable declaration.
- Factorial Using Loop Example Program In C++ — More in c common example program.
- Factorial Using Function Example Program In C++ — More in c common example program.
Frequently Asked Questions
What does this C++ program do?
It is a C++ example program that demonstrates Area of Circle Example, including the complete source code and the expected sample output.
How do I compile and run this C++ program?
Save the code in a `.cpp` file, compile it with `g++ filename.cpp -o program`, then run it with `./program` (or `program.exe` on Windows).
What concepts does this example use?
This example uses reading user input, illustrating a common pattern in C++ programming.