Link to home
Start Free TrialLog in
Avatar of inzhagi
inzhagi

asked on

Programs that read in the radius of a circle and prints the circle diameter....

Hai there...i need to write a program that reads in the radius of a circle and prints the circle diameter,circumference and area. The constant value is 3.14159 for pie. For example if the user enter 5, then it will shows the result of

Diameter=10
Circumference=31.4159
Area=78.5397

Formula for the circumference and area of circle are C= 2 pie radius and A=pie radius^2
ASKER CERTIFIED SOLUTION
Avatar of DrAske
DrAske
Flag of Jordan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of inzhagi
inzhagi

ASKER

#include <iostream.h>
main()
{
      
      const double pie = 3.14159;
      double  r;
      double  D;
      double  C;
      double  A;

      cout <<"Enter the radius"<< endl;
      cin >> r ;

      D = 2*r;
      C = 2*pie*r;
      A = pie*r*r;

      cout <<"Diameter:"<<D<<"D"<<endl;
      cout <<"Circumference:"<<C<<"C"<<endl;
      cout <<"Area:"<<A<<"A"<<endl;

      return 0;

}

i get an error
what kind of error ??
i ran the code and it give me the expected result !!!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Venabili ..

I tried to help him to accomplish his homework , and I think the asker respond to my comment and gave a full code for the solution .(I guess he followed the steps I provided in my first comment to write the code),BUT I think he solved the error after posting his code -THAT WHY HE DID NOT POST THE ERROR-.

regards, Ahmad;
Well, Venabili ..
are you going to refund or accept an answer??