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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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