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

  Program that generates 50,000 random integers

Program that generates 50,000 random integers from 1 to 6 (inclusive). Count the number of times that each number occurs and output the totals

  Pseudocode for constructing the reverse of an input string

For each position of the string starting at the end working backwards - Append the character at that position to the reverse of the string.

  Repare a c++ class derived that inherits from base class

Write a C++ class Base has two member functions: //add constructor(s) if needed int f () {return x*25;} //x is a protected data member of Base class virtual int g() {return x *35; }

  Create a program that would give you the day of the week

Create a program that would give you the day of the week if you entered month/date/year. please show every step.

  Create a c++ function named pathexists

Write a C++ function named pathExists that determines whether or not a there's a path from start to finish in a 10x10 maze. A 2-dimensional 10x10 character array of Xs and dots that represents the maze. Each 'X' represents a wall, and each '.' rep..

  Build a randomly generated simple substitution cipher

Design, implement and test classes in C++ Apply and implement ? overloaded? operators and functions Design and implement classes using inheritance

  Compute square roots to a desired degree of accuracy

write a program which will compute square roots to a desired degree of accuracy.

  The method takes an array

The method takes an array of integers and returns true if there exists any item in the array that satisfies a specified condition. For instance, the following code fragment:

  Aimthis assignment is designed to apply your knowledge on

aimthis assignment is designed to apply your knowledge on microcontroller to build a traffic light system. you are

  Write a program to determine how long ball moves

Using the v2 form of drag, write a program to determine how long (sec.) and how far (m) a 150 gram ball whose radius is 3.5cm would fall before it reached 75% of its terminal velocity.

  Calculate the gross pay of a set of employees

Write a C program that will calculate the gross pay of a set of employees - For each employee the program should prompt the user to enter the clock number, wage rate, and number of hours

  Program that asks user to enter text and show given output

Write a program that asks the user to enter some text and then displays that text with all e's and E's replaced with 3's and all s's and S's replaced by 5's.

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