Write a program and estimate pi using 400, 4000, 40000, 4000

Consider a dartboard of radius 1. Since the area of the board will be  π r2 = π * 1 *1, it's clear the area of the dartboard is exactly π. The area of a square surrounding the board (circumscribing it) would be 2*2 = 4, since the diameter or the dartboard is 2 (twice the radius) and the diameter equals length of a side of the square. Now, if we introduce a set of darts, where the x and y range from -1 to +1, we simulate a random sampling of all positions on the square surrounding the dartboard, some on the board and some of the square surrounding it. You can determine whether the dart hit the board or not by simply calculating if its distance from the center of the dartboard is greater than 1 (off the board) or <=1 (on the board). If we toss 4 darts, corresponding to area of the square, we will expect π darts, on average, to hit inside the dartboard and the remainder to miss. By extension, if we toss 40000 darts, 10000*π  should hit the dartboard. We can use this largest set to give us a decent estimation.

 

   Related Questions in Programming Languages

  • Q : Define PS3 Debug/TEST/Prototype

    Define PS3 Debug/TEST/Prototype Consoleroduction deployment.

  • Q : State the term VHDL or Verilog State

    State the term VHDL or Verilog? Answer: VHDL is extremely high speep integrated chips hardware descripted language as well as verilog is use to verify logic.

  • Q : What is Final method Final method :

    Final method: This is a method with the final reserved word in its header. The final method might not be overridden by a method stated in a sub class.

  • Q : Self-created What is the difference

    What is the difference among a self-created certificate, Symbian Signed and a Symbian developer certificate?

  • Q : Define Accessor method Accessor method

    Accessor method: A technique specifically designed to offer access to a private attribute of a class. By convention, we name accessors with a get prefix followed by the name of the attribute being accessed. For example, the accessor for an attribute n

  • Q : Explain Swing Swing : The Swing classes

    Swing: The Swing classes are portion of a wider collection termed as the Java Foundation Classes (abbreviated as JFC). The swing classes are stated in the javax.swing packages. They give a further set of components which extend the capabilities of Abs

  • Q : Explain the differences between HTML

    Explain the differences between HTML and XML?

  • Q : What is an Instantiation What is an

    What is an Instantiation: It is a creation of an instance of a class, i.e., an object.

  • Q : Define Compilation Compilation : It is

    Compilation: It is a process of translating a programming language. This frequently comprises translating a high level programming language into a low level programming language, and the binary form of a specific instruction set. The translation is ex

  • Q : Data types of LONG To define the data

    To define the data types such as LONG, INT, SHORT, CHAR write a program?

©TutorsGlobe All rights reserved 2022-2023.