Given a function Rand() that returns a random value between 0(inclusive and 1.0 (exclusive), write the following randomfunctions:
a. A random function which ranges between 0 and N.
int randNat (int N) {}
b. A random function which ranges between 1 and N.
int randPos (int N) {}
c. A random integer function which ranges between two integers Aand B, such that A<=B.
int randRange (int A,B) { }
d. A random positive integer function whose average is A.
int randAvg (int A) {}
e. A random Boolean function which returns TRUE on average onceevery N calls.
bool randEvent (int N){ }
Given a function Rand() that returns a random value between 0 (inclusive and 1.0 (exclusive), write the following random
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am