answersLogoWhite

0


Best Answer

#include <iostream>

// Required to calculate pi more accurately:

//#include <math.h>

int main()

{

const double pi = 3.14;

// To calculate pi more accurately, use:

// const double pi = 4*atan(1.0);

double r;

while( 1 )

{

printf( "Calculate the area of a circle.\n" );

printf( "Enter 0 to exit.\n" );

printf( "Enter the circle's radius: " );

if( std::cin >> r )

{

if( !r )

{

printf( "\n" );

break;

}

printf( "Area of circle is: %.2f\n\n", pi * r * r );

}

else

{

printf( "Invalid input. Please try again.\n\n" );

std::cin.clear();

while( std::cin.get() != '\n' ) ;

}

}

return( 0 );

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Ask the user to input the radius and compute of the area of circle given the pie equals 3.14 in dev-c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you compute instantaneous value at given time of three phase alternator?

your mom nothing


In Turing write a program that prompts for the radius of a circle then calculates and outputs the circumference?

I'm not sure how you'd do this in C++, but I could have a go at it in php since that's what I know. You know that Pi is approximately 22/7, in php you can use the pi function. You'd need your input(radius) to come from a form if it was web-based, which is simple enough. perimeter = 2nr = 2 x (22/7) x r function getPerimeter ($input) { $input = $_GET['formInput']; $pi=pi(); $perimeter = (2*$pi)*$input; return $perimeter; } HTH


How do you calculate the point on the edge of a circle that corresponds to a degree given the radius of the circle?

public void getPoint(double r, double angle) { //cosine*hypotenuse=adjasent double x = r * Math.cos (Math.toRadians(angle))//in radians; //sine * hypotenuse =opposite double y=r*Math.sin(Math.toRadians(angle))//also in radians; System.out.println("( "+x+", "+y+" )"); }


How do you find the diameter of a length of string?

You use the diameter formular. You know, C=pi(d). If you know the cicumference, then you use this equation, d=c/pi. You subsitute the cimcumference and divide (pi=3.14), and that's how you calculate dimater. Oh yeah, and if your given the radius of the circle, just multiply it by two.Type your answer here...


To draw a circle and show its movements using c plus plus graphics?

There are several options to draw a circle using C or C++ without the built-in functions... &lt;&gt; &lt;&gt; &lt;&gt; &lt;&gt; If you can draw a single pixel at a time, use a for loop to iterate Angle from 0 to 2*pi. Then plot a pixel with x=cos(Angle) and y=sin(Angle). Smaller steps will give better results. Lines from one point to the next may look nicer. Generally, you can use a line from one pixel to the next to draw a polygon. The number of sides is determined by the number of steps from 0 to 2*pi. A circle is a polygon with an "infinite" number of sides (compared to the display resolution). Experiment with non-integral steps to see that the polygon can end at any place. Use an integral number of steps to end where the circle began. Start and stop at fractions of 2*pi, or step backwards, to create arcs. Speed up the code by using lookup tables to calculate sin() and cos(). Hint: they can be the same table, and don't need to be a complete 2*pi circle. &lt;&gt; &lt;&gt; &lt;&gt; &lt;&gt; You can also draw the circle without the sin() and cos() functions if you understand the trigonometry behind sin() and cos(). Recall that sin(theta) is radius / y, and cos(theta) is radius / x, given that x and y are the two sides of a right triangle and that radius is the hypotenuse. By Pythagoream's theorem, x2 + y2 is radius2. It is then simple to solve for x or y, given the other along with radius. You also do not need to compute for the whole circle - you can compute for one quadrant, and generate the other three quadrants by symmetry. You generation loop would, for example, simply iterate from origin to radius as x by delta x, generating y, and reflecting that in the other three quadrants. You can also compute for one half of a quadrant, and use both symmetry and reflection to generate the other seven half quadrants.

Related questions

When you are given pi of a circle how do you find the radius and diameter?

you cant: pi is the same for any circle - 3.1415... the diamter or the radius has to be given diameter divided by two equals the radius the radius times two equals the diameter


How do you find the radius of an inscribed circle of a square given the area of the square?

Half the square root of the square radius equals the circle radius.


Given the circumference of a circle what is the radius?

Circumference equals the diameter times pi. The diameter is 2 times radius. Radius equals Circumference divided by pi then divided by 2.


How do you find distance if radius is given?

Diameter of a circle = 2*radius Circumference of a circle = 2*radius*pi


If the circumference of a circle is 2053 feet what is the radius of the circle?

Given the circumference of a circle the radius is: r = C / 2xPI So the radius of your circle is 326.7451 ft


What is the radius of a circle given an arc and its height?

if you are given the circle's "height" then that is the diameter. the diameter is twice the length of the radius, so divide the height by two and you will get the radius.


How do you find the diameter of a circle given the radius?

Double the radius


What is the radius of a circle with a given diameter?

Radius = Diameter/2.


What are 5 formulas that use pi in geometry?

Circumference of a circle given radius Area of a circle given radius Volume of a sphere given radius Surface area of a sphere given radius Converting degrees to radians or vice versa


How do you find the area of a circle when the radius is unknown?

By using the other information supplied about the circle to calculate either its radius (from which its area can be calculated) or its area (if the circle is similar to another with a given area and some ratio between the two circle is given):If the diameter is given: radius = diameter &divide; 2If the circumference is given: radius = circumference &divide; 2&pi;If the circle is similar to another circle which has a given area, and the length ratio is given; square the length ratio to get the area ratio and apply to the given area.


What is the formula for the diameter or a circle?

If you are given the radius of the circle, you can use the formula: diameter = 2*radius If you are given the circumference of the circle, you can use the formula: diameter = circumference/pi


How do you find radius of a circle if cord length is given?

The longest chord in a circle is its diameter and halve of this is its radius.