subject area of cirlce. - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

subject area of cirlce.

talhanasirtalhanasir Posts: 13Member
what is meaning of double-precision in the following question?
[blue]
Write a function that returns the double-precision area of a circle, given the double precision radius passed to it. The formula to calculate the radius of a circle is .

area = 3.14159 * radius * radius.

what will be the value of radius.? [/blue]

and what will be the value of radius in above question?
Talha Nasir

Comments

  • HK_MP5KPDWHK_MP5KPDW Posts: 770Member ✭✭✭
    : what is meaning of double-precision in the following question?
    : [blue]
    : Write a function that returns the double-precision area of a circle, given the double precision radius passed to it. The formula to calculate the radius of a circle is .
    :
    : area = 3.14159 * radius * radius.
    :
    : what will be the value of radius.? [/blue]
    :
    : and what will be the value of radius in above question?
    : Talha Nasir
    :
    :

    [green]Use [italic]double[/italic] variables as opposed to [italic]float[/italic] for [italic]radius[/italic] and [italic]area[/italic]. How the heck do I know what the value of radius is going to be? I'm not clairvoyant/omniscient.[/green]
  • IDKIDK Posts: 1,784Member
    : : what is meaning of double-precision in the following question?
    : : [blue]
    : : Write a function that returns the double-precision area of a circle, given the double precision radius passed to it. The formula to calculate the radius of a circle is .
    : :
    : : area = 3.14159 * radius * radius.
    : :
    : : what will be the value of radius.? [/blue]
    : :
    : : and what will be the value of radius in above question?
    : : Talha Nasir
    : :
    : :
    : How the heck do I know what the value of radius is going to be? I'm not clairvoyant/omniscient.[/green]
    :
    With some math it should be:
    raduis = sqrt(area / 3.14159)
  • zeolitezeolite Posts: 78Member
    That should be exactly what you need:[CODE]double AreaOfCircle(double radius)
    {
    return 3.14159 * radius * radius;
    }[/CODE]

    : what is meaning of double-precision in the following question?
    : [blue]
    : Write a function that returns the double-precision area of a circle, given the double precision radius passed to it. The formula to calculate the radius of a circle is .
    :
    : area = 3.14159 * radius * radius.
    :
    : what will be the value of radius.? [/blue]
    :
    : and what will be the value of radius in above question?
    : Talha Nasir
    :
    :
  • FDracheFDrache Posts: 64Member
    : That should be exactly what you need:[CODE]double AreaOfCircle(double radius)
    : {
    : return 3.14159 * radius * radius;
    : }[/CODE]
    :

    That's it! And to be exact, define and take
    const double pi = 2.0 * acos(0.0); // 2*arccosine(0)
    because pi is usually not defined in C libraries.
    FDrache.


Sign In or Register to comment.