# Programming PI

• 11-05-2001
jill
Programming PI
VisualC++6.0
This is for a Calculate the area of a circle given the diameter.

Ok this is what I have so far;
#include<math.h>
voidmain(void)
{
pie,diameter,areais,sqrt(2);

cout<<"Enter Pie ";
cin>>Pie;
cout<< "Enter Diameter ";
cin>>diameter;
cout<< "Enter Area Is ";
cin>>areais;
cout<< "EnterSquare(2) ";
cin>>sqrt(2)

pie *4Sqrt(2)

Do I have everything so far.
• 11-05-2001
Unregistered
No.
• 11-06-2001
Salem
To calculate the area, you only need input the diameter.

You've got cout and cin sorted, but you need to work on declarations and assignments
• 11-06-2001
Stoned_Coder
when i was at school PI * r*r gives the area of a circle. Given that r= 0.5*d this problem should be easy.

Code:

``` #include<iostream> using namespace std; int main() // not void main() cos thats illegal { const double PI= 3.14159 // you might have to check that value cout<<"Enter diameter"; double diameter,radius; cin>>diameter; radius=diameter*0.5; double area=radius*radius*PI; cout<<endl<<"Area of circle is "<<area<<" units squared"<<endl; return 0; }```