Circumference of a Circle

   Circumference and Area of a Circle

Compute the area and circumference of a circle given the radius. The input/output behavior of the program should be

Circle radius(real number)?     5.1

Area of Circle with radius 5.1 is 81.7104

Circumference is 32.0433

 

 

Before we can the program , we must consider a number of issues. Recall that the area of a circle is . C++ does not have a exponentiation operator, but this operation is easily handled by multiplying the radius is Radius, the area of the circle can be computed by the expression

3.1415*Radius*Radius

Because we wish to allow  the user to input a floating-point value as the radius, Radius should be a C++ floating-point type. Since the problem statement did not specify the possible size of the radius, or the accuracy of the result, we will arbitrarily choose type float for Radius.

//Program area and circumference of circle given radius

#include<iostream.h>

#include<conio.h>

void main()

{

     cout<<"circle radius(real number)?";

     float Radius;

     cin>>Radius;

     cout<<"Area of circle with radius"<<Radius<<"is"<<(3.1415*Radius*Radius)<<endl;

     cout<<"Circumference is"<<3.1415*2*Radius<<endl;

     getch();

}

Output......

Circumference and Area of Circle

 

 

About Us

Rekha SetiaRekha Setia is a passionate blogger of Extra Computer Notes. if you have any ideas or any request me @