Link to home
Start Free TrialLog in
Avatar of marcuskhor
marcuskhor

asked on

write a program that reads in the radius of a circle

and prints the circle's diameter, circumference and area. Use the constant value 3.14159. Do each of these calculations inside the prints statements and use the conversion specifier %f.

anyone can helps me, i am a novice of C++, so please, THANKS.
Avatar of marcuskhor
marcuskhor

ASKER

thanks for devx.com, it helps me a lot and thanks for those who answers my question.
#include <iostream.h>

void main()
{
     double r;
     double area, circum, dia;
     const double pi = 3.14159;

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

     area = pi * r * r;
     dia = 2 * r;
     circum = pi * dia;

     
     cout << "\nRadius entered :" << r << "\n";
     cout << "Area :" << area << "\n";
     cout << "Diameter :" << dia << "\n";
     cout << "Circumference :" << circum << "\n";
     return;
}

You can make this code more fashionable. But since you said you are a novice this would be more simpler to start with. You can also use printf statements and specify %f inside them. But using cout, cin would be more of C++ then using printf and scanf which are C functions.

By the way, is this what you want?
We cannot do your schoolwork for you.  That is unethical and is grounds for removal from this site.  (for both you and the experts involved.)  

We can provide only limitied help in accademic assignments.    We can answer specific (direct) questions, like you might ask your teacher.  We can review your work and post suggestions, again, like your teacher might do.

Do you have specific questions?
Do you have any work on this (incomplete even) that we can review?

********************************

omkamal, don't help people cheat!
Marcuskhor,

Nietod may be right. I am wondering why you asked such a question in the expert zone. Please do not try to waste others time. Forgive me if I really hurted you. All we say is such a question is an exercise that can be found in any beginner's c++ book or any c++ learning website. We all try to be helpful here. But not for anything in the world. Knowledge Exchange Expert Zone has got specific goals. See you back in 5 or 6 months.
hi all .

your problem is both c++ language and mathematics .

I can offer my help by solving (try) hardest mathematical
problems .

Tal
omkamal ,
   There is nothing wrong with a beginner asking for help here.  But a student cannot ask use to do their work for them.  they can only ask for _assistance_.  Like tutoring.
ASKER CERTIFIED SOLUTION
Avatar of amp072397
amp072397

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
Closed by
EE Moderator