C Implementation
/* This program approximates the integral e^(-x^2/2) from 0 to 1 by using Monte Carlo integration.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define dran(u1) \
( (rand()/(double) \
RAND_MAX)*(u1))
#define Prompt(p) printf(p)
#define Response(r) \
scanf("%d", &r)
#define Answer(a) \
printf("Integral = %f\n", a)
double area(int);
main()
{ . . .
Previous slide
Next slide
Back to first slide
View graphic version