0 votes
in Swift by
What is the general form of Random number generation in Swift?

A

let number = min + arc4random_uniform(max + min + 1)

B

let number = min + arc4random_uniform(max , min + 1)

C

let number = min + arc4random_uniform(max - min - 1)

D

let number = min + arc4random_uniform(max - min + 1)

1 Answer

0 votes
by
Answer: D

Reason:  There are three typical functions for random numbers: arc4random() returns a random number between zero and (2^32 or UInt32.max) – 1 arc4random_uniform(n) returns a random number between zero and the (parameter minus one). drand48() returns a random Double between 0.0 and 1.0 let number = min + arc4random_uniform(max - min + 1) where number, max, and min are UInt32. But these are not recommended for cryptography or security purposes as they appear random but numbers from these functions are generated with a mathematical formula changes of reptpitions are possible.

Related questions

0 votes
asked Nov 8, 2022 in Swift by SakshiSharma
0 votes
0 votes
asked Nov 7, 2022 in Swift by Robin
...