Solved

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

Posted on 2006-06-24
10
585 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:inzhagi
  • 4
10 Comments
 
LVL 9

Accepted Solution

by:
DrAske earned 50 total points
ID: 16976629
Okay ..i won't give a full code ..
but as i see in your description all you have to do is put what you descriped in small program ..
so first implement the *main* (inside it ask the user to enter the radius of a circle, then save it in a variable say; *Radius* of type double,integer, or float .. )
then add statements specific for each operation (circle diameter, circumeference, and area) ..
not that hard!!
Diameter is calculated by multiply the value by 2 ..
then declare a variable say; *Diatmeter* and assign to it the result of multipling the input value by two ..
then use *cout* function to show the result ..
and do so with others; declare variable and assign to it the result of the mathmatical process .. etc

e.g:

double Radius = 5;
double Area = pie*pow(Radius,2);
cout<<"The Area is : "<<Area<<endl;
 
regards, ahmad;
0
 

Author Comment

by:inzhagi
ID: 16977490
#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
0
 
LVL 9

Expert Comment

by:DrAske
ID: 16978576
what kind of error ??
i ran the code and it give me the expected result !!!
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 25

Assisted Solution

by:InteractiveMind
InteractiveMind earned 50 total points
ID: 16978733
#include <iostream>
using namespace std;

int 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;

}
0
 
LVL 9

Expert Comment

by:DrAske
ID: 17231143
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;
0
 
LVL 9

Expert Comment

by:DrAske
ID: 17258714
Well, Venabili ..
are you going to refund or accept an answer??
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
why "." vs "->" 23 120
C Language combined operators 28 109
Which IDE to use to begin C++ training? 5 63
I could not build boost code, 10 88
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question