answersLogoWhite

0

//Program to calculate the value of pi using monte carlo method:

/*

NADEEM AHMAD

MCA 2012

NITISH HOODA

M TECH 2012

SHARDA UNIVERSITY

GREATER NOIDA*/

#include<stdlib.h>

#include<stdio.h>

#include<math.h>

#include<string.h>

#include<conio.h>

#define SEED 35791246

void main(int argc, char* argv)

{

int niter=0;

double x,y;

int i,count=0; /* # of points in the 1st quadrant of unit circle */

double z;

double pi;

printf("Enter the number of iterations used to estimate pi: ");

scanf("%d",&niter);

/* initialize random numbers */

srand(SEED);

count=0;

for ( i=0; i<niter; i++) {

x = (double)rand()/RAND_MAX;

y = (double)rand()/RAND_MAX;

z = x*x+y*y;

if (z<=1) count++;

}

pi=(double)count/niter*4;

printf("# of trials= %d , estimate of pi is %g \n",niter,pi);

getch();

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Continue Learning about Engineering

When I start a 1996 Monte Carlo with the 3.4 DOHC motor it has an idle speed of 1000 rpms is that normal for this motor?

that would be good for the cold idle and should drop three times as the car warms up and should idle about 650 to 800 auto trans


How do you record a call conversation in Samsung Monte S5620?

Its impossible in samsung monte gs5620 . other wise seperate software required


What is the biggest circuit?

The biggest circuit in terms of size is the Monaco Grand Prix circuit, known for its challenging street layout in Monte Carlo. However, in terms of length, the Nürburgring Nordschleife, often referred to as &quot;The Green Hell,&quot; is one of the longest permanent race tracks, measuring about 20.8 kilometers (12.9 miles). Each circuit has its unique characteristics and challenges that attract motorsport enthusiasts worldwide.


What is the education required to become an Illumination engineer?

Competitive candidates will have a minimum of a BS in Physics, Optical Engineering, or a similar discipline, and 5+ years of experience in illumination system design or optical engineering with experience related to illumination systems. Candidates should also have 2+ years of experience utilizing technical program management disciplines. Illumination projects require a strong CAD background, preferably utilizing a surface based modeler such as Rhinoceros&reg; ("Rhino") or a solid modeler such as SolidWorks&reg;. Experience with ASAP and ReflectorCAD, or other Monte-Carlo ray trace simulation programs and a solid understanding of different types of illumination systems are required. Candidates who have knowledge of ASAP preferred. (this is from a job search description)


What is randomized algorithm?

A randomized algorithm is an algorithm that uses random numbers or randomization as part of its logic to make decisions or perform computations. It can provide faster or simpler solutions to certain problems compared to deterministic algorithms, which follow a fixed sequence of steps. Randomized algorithms are particularly useful in scenarios where the input size is large or where the problem space is complex, enabling more efficient exploration of potential solutions. Examples include randomized quicksort and Monte Carlo methods.

Related Questions

What has the author Reuven Y Rubinstein written?

Reuven Y. Rubinstein has written: 'Simulation and the Monte Carlo Method' 'Simulation and the monte carlo method' -- subject(s): Monte Carlo method, Digital computer simulation 'Monte Carlo optimization, simulation, and sensitivity of queuing networks' -- subject(s): Mathematical models, Monte Carlo method, Queuing theory


What has the author J M Hammersley written?

J. M. Hammersley has written: 'Monte Carlo methods' -- subject(s): Probabilities, Monte Carlo method


What has the author William L Dunn written?

William L. Dunn has written: 'Exploring Monte Carlo methods' -- subject(s): Monte Carlo method


What has the author Y A Schreider written?

Y. A. Schreider has written: 'The Monte Carlo method'


What has the author C Moglestue written?

C. Moglestue has written: 'Monte Carlo simulation of semiconductor devices' -- subject(s): Computer simulation, Mathematical models, Monte Carlo method, Semiconductors


What has the author Ralf Korn written?

Ralf Korn has written: 'Monte Carlo methods and models in finance and insurance' -- subject(s): Mathematics, Monte Carlo method, Business mathematics, Insurance


Is Monte Carlo in Monaco?

Yes, Monte Carlo is in Monaco.


What has the author Chester Lewellyn Olson written?

Chester Lewellyn Olson has written: 'A Monte Carlo investigation of the robustness of multivariate analysis of variance' -- subject(s): Monte Carlo method, Multivariate analysis


What is the distance in kilometres from montpellier France to Monte Carlo France?

Monte Carlo is in Monaco ! There are 350 kms from Montpellier to Monte Carlo


Will 2010 Monte Carlo front cap fit a 1986 Monte Carlo?

There is no such thing as a 2010 Monte Carlo, so the answer would be no


Which country is Monte Carlo?

The town of Monte Carlo is in the country of Monaco


Will there be a 2008 model for the Monte Carlo?

No, the Monte Carlo was discontinued in 2007