What will be the nature of the output of the program? [code] long rn; void setup() { Serial.begin(9600); randomSeed(analogRead(0));

Nguyên Lê

New member
What will be the nature of the output of the program?
Code:
long rn; 
void setup() { 
    Serial.begin(9600); 
    randomSeed(analogRead(0)); 
} 
void loop() { 
    randNumber = random(300); 
    Serial.println(rn);
    delay(1000);
}
A. Series of purely mathematical indeterministic random numbers
B. Series of purely mathematical deterministic random numbers
C. null
D. Series of indeterministic random numbers based on noise
 
Answer: D
Explanation: The function here attempts to generate random numbers based on the analog noise generated at one of the pins present in the board. This will create a seemingly indeterministic set of numbers ranging from 0 to 300, which is great for a random number generator function.
 

Tìm kiếm

Back
Top