Calculate the area of circle by C++ program.

Asked By 10 points N/A Posted on -
qa-featured

Write a C++ program to calculate the diameter, circumference and are of circle.

Program will take the radius from the user as input. Print all results.

 

 
SHARE
Best Answer by faisal256
Answered By 0 points N/A #124174

Calculate the area of circle by C++ program.

qa-featured

hi,

It is a very simple program and you should be able to solve it even if i provide you the algorithm. however as you have put the question,here is your required answer:

in order to find get the radius from the user first ,you need to declare the variable :

double radius;

cin>> radius;

now you need to declare the rest of variables.
double PI = 3.14159;

double diametre;
double area;

double circumference;

in order to calculate the diametre:

diametre=radius+radius;

in order to calculate the area:
area = PI * (radius * radius);

in order to calculate the circumference:

circumference = PI * (radius +radius)

cout<<radius<<diametre<<area<<circumference;


Janet//

 

Best Answer
Best Answer
Answered By 0 points N/A #124175

Calculate the area of circle by C++ program.

qa-featured

Following is the code for the program to calculate diameter , circumference , and area of circle.  The different steps of the program are explained with the comments ahead of the respective statement. The program can be best run on Turbo C , Visual Studio 2005 , 2008 , 2010 .

#include<iostream>

usingnamespacestd;

intmain()

{

doubler;

      doubledia, cir , area =0.0;   // declare and initialize variables

      doublepi  = 3.141592654;

      cout<<"Enter radius of Circle: ";

      cin>> r;                       // Take radius as input from user

      dia = 2*r;                    // Calculate diameter

      cir = 2*pi*r;                 // Calculate circumference

      area = pi*r*r;                // Calculate area

      // Print results on screen

      cout<<"Diameter is: "<< dia<<endl;

      cout<<"Cirumference is: "<<cir<<endl;

      cout<<"Area is: "<<area<<endl;

       return0;

}

In order to see the output of program check attachment

Regards

Faisal Rehman

Related Questions