COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
main3.cpp File Reference
#include <iostream>
#include "random.h"
Include dependency graph for main3.cpp:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( void )

Definition at line 5 of file main3.cpp.

5 {
6
7 int n = 1000000;
8 int count = 0;
9
10 for(int i = 0; i < n; ++i) {
11 double x, y;
12 randomPoint(x, y);
13 if(x*x + y*y < 1) {
14 ++count;
15 }
16 }
17
18 cout << 4.0 * count / n << endl;
19
20 return 0;
21}
void randomPoint(double &x, double &y)
Definition random.cpp:5

References randomPoint().

Here is the call graph for this function: