C++ Program to Find Area of a Circle:
To calculate area of circle in C++ programming, you have to ask from user to enter the radius of circle, place the radius in a variable say radius and then initialize 3.14*radius*radius in a variable that holds the value of area of circle.
C++ program:
Source Code:
// C++ Program to Find Area of a Circle
#include<iostream>
/* iostream provides basic
input and output services for C++ programs */
using namespace std;
int main()
// Th execution of program start with the main function
{
float radius, area;
//Variable Declarations specify the type followed by the name
cout<<"Enter the Radius of Circle: ";
// cout is used to display the same statement in the output.
cin>>radius;
// cin is used to enter the value by the user.
// formula
area = 3.14*radius*radius;
cout<<"\nArea of Circle = "<<area;
cout<<endl;
// endl is used to enter the new line character
return 0;
}
0 Comments