Evaluate the mathematical constant of p

Assignment Help C/C++ Programming
Reference no: EM13711339

Program: Write a C++ program to evaluate the mathematical constant of PI:

Part (1) Imagine a circle, whose area is given by: Area=PI*R^2

Part (2) Now imagine that you divide the circle exactly into 4 quadrants.

Part (3) The area of one quadrant is hence: Area=0.25*PI*R (d) Now let us set the radius to be R=1;

Part (4) The equation hence becomes: Area=0.25*PI

Part (5) So we can simply say: PI = Area*4

y-axis

x=0 y=1

x=0 y=0

Note that this square is 1.0 x 1.0 in size.

x-axis

???????x=1 y=0

The question is how do you evaluate the area of the grey shaded quadrant of the circle above?

Use a random number generator and guess effectively the correct solution.

(Hint: use rand() from <cstdlib> and make sure that you divide through by RAND_MAX.)

The method you should use is to:

1. Guess a random number between 0.00 and 1.00 and assign this to x.

2. Guess a random number between 0.00 and 1.00 and assign this to y.

3. Find out if this (x,y) coordinate lies inside the grey shaded quadrant or outside. Hint: sqrt(x +y ).

4. Repeat these steps N times, where N is sufficiently big and then find the ratio of points inside the circle divided by the total number N, to determine the area of the grey shaded area.

5. Apply this to your equation to find the mathematical constant PI.

Reference no: EM13711339

Questions Cloud

Na2co3 precipitate form mgcl2 are mixed : 100.0mL of 0.00100M Na2CO3 and 100.0mL of 0.00200M MgCl2 are mixed. Will a precipitate form. Justify your choice mathematically.
Describe the pillars of electronic commerce : Identify and describe the three pillars of electronic commerce - What is the "value chain"? Contrast the traditional value chain with the customer-oriented value chain.
Calculate the freezing point of solution that contains urea : Calculate the freezing point of a solution that contains 30.8 g of urea, CH4N2O (MW = 60.06 g/mol), in 196 g of water. Urea is a nonvolatile nonelectrolyte. Kf for H2O = 1.86°C/m.
Describe technology and innovation management research : This activity requires you to write a Research Paper on a subject of your choice within Technology and Innovation Management.
Evaluate the mathematical constant of p : Write a C++ program to evaluate the mathematical constant of PI - Guess a random number between 0.00 and 1.00 and assign this to x.
Calculate the molecular weight of the unknown nonelectrolyte : Calculate the molecular weight of the unknown nonelectrolyte. The Kb for benzene = 2.53°C/m. The boiling point of pure benzene is 80.1°C.
Explain the technology & sustainability issues : describe the technology and sustainability issues Anglo American case study and compute how technology, process and product development enable a large company like Anglo American.
Human factors to consider when building a web site : What are some human factors to consider when building a Web site and what are some technical factors to consider when building a Web site?
Values expect for the c to cl bond energy : The energy of the C-----C bond id 347 KJ/mol, and that of the Cl------Cl bond is 243 KJ/mol. which of the following values might you expect for the C-----Cl bond energy. Explain.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Creates an array of six divsales objects

Write a program that creates an array of six DivSales objects. The program should ask the user to enter the sales for four quarters for each division. After the data are entered, the program should display a table showing the division sales for ..

  Individual genes are substrings of a genome

Individual genes are substrings of a genome delineated by 3-element start and stop codons. Genes begin with the start codon ATG and end with one of the following 3 stop codons: TAG, TAA or TGA. Note that start codons can appear anywhere in the string..

  Write a function named xytopolar

Write a function named "XYtoPolar" that has 2 double value parameters and 2 double reference parameters that converts x,y coordinates to polar coordinates. The prototype is: void XYtoPolar(double x, double y, double* angle, double* radius);

  Write a program that reads in babynames

Write a program that reads in babynames.txt and produces two files - Separate the data for the boys and girls. You may enter any names

  Prompt the user for 3 sentences of text

Prompt the user for 3 sentences of text. Pass these pieces of text into a function connect() which will connect all three sentences into one long sentence. Pass the combination sentence back to the main program, where it is printed.

  Implement a simplified version of the set class

You will implement a simplified version of the set class. You must implement all functions defined in the provided file set.h. You may add other member functions and variables as necessary.

  Calculating the gcd greatest common divisor

Write a C++ code for calculating the GCD Greatest Common Divisor between two positive integer numbers. You  should  use Euclid's  original  subtraction  based  GCD algorithm ( not  using  modulo operator).

  Find the area of the circle

What is the ratio of the areas of the inscribed circle to that of the unit square -

  Prepare a program to show the fibonacci numbers

Write a C++ program to display first 20 Fibonacci numbers in descending order - Prepare a program to show the Fibonacci numbers

  Problems on oops

Problems on OOPS

  Create a program for a company named retail-martprompt the

create a program for a company named retail-martprompt the user to enter an item name one word only a quantity and a

  Implement the graphics portion of the assignment

Analyze a basic set of requirements for a problem - Compose basic C++ language programs

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd