Question
Consider the following program and fill in the blanks in lines 5 with appropriate code. What will be the output in line 16 if random(1,2)
Consider the following program and fill in the blanks in lines 5 with appropriate code. What will be the output in line 16 if random(1,2) returned 1 at line 13?
1 FUNCTION String coinToss(Integer rValue)
2 IF rValue == 1 THEN
3 RETURN "head"
4 ELSE
5 RETURN "________"
6 END IF
7 END FUNCTION
8
9 MODULE main()
10 DECLARE Integer rand
11 DECLARE String value = ""
12
13 SET rand = random(1,2) //generate a random number
14
15 SET value = coinToss(rand)
16 DISPLAY "You got ", value
17 END MODULE
tail; You got head
rValue; You got tail
head; You got tail
rand, You got head
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started