Conditionals MCQ Practice

Question 1 of 10

For limit = 25, what is displayed?

IF (limit = 25)
{
  DISPLAY ("exact")
}
ELSE
{
  DISPLAY ("other")
}
  1. A. 25
  2. B. exactother
  3. C. exact
  4. D. other

Question 2 of 10

fuel is 10. What is displayed?

IF (fuel <= 10)
{
  DISPLAY ("refuel")
}
ELSE
{
  DISPLAY ("ok")
}
  1. A. ok
  2. B. 10
  3. C. refuelok
  4. D. refuel

Question 3 of 10

Which value of t runs the THEN branch?

IF (t < 0)
{
  DISPLAY ("negative")
}
ELSE
{
  DISPLAY ("not negative")
}
  1. A. -1
  2. B. 2
  3. C. 0
  4. D. 1

Question 4 of 10

A ticket scanner uses the segment with tickets = 1. Both messages are plausible for a gate. What is displayed?

IF (tickets > 1)
{
  DISPLAY ("group entry")
}
ELSE
{
  DISPLAY ("single entry")
}
  1. A. group entry
  2. B. single entry
  3. C. group entrysingle entry
  4. D. 1

Question 5 of 10

For height = 48, what is displayed?

IF (height >= 48)
{
  DISPLAY ("ride ok")
}
ELSE
{
  DISPLAY ("too short")
}
  1. A. 48
  2. B. Nothing is displayed.
  3. C. ride ok
  4. D. too short

Question 6 of 10

Trace with count = 3.

IF (count > 3)
{
  label โ† "many"
}
ELSE
{
  label โ† "few"
}
DISPLAY (label)
  1. A. 3
  2. B. manyfew
  3. C. many
  4. D. few

Question 7 of 10

minutes is 60. What is displayed?

IF (minutes < 60)
{
  DISPLAY ("under an hour")
}
ELSE
{
  DISPLAY ("hour or more")
}
  1. A. hour or more
  2. B. 60
  3. C. under an hourhour or more
  4. D. under an hour

Question 8 of 10

Which input displays "high"?

IF (pressure >= 30)
{
  DISPLAY ("high")
}
ELSE
{
  DISPLAY ("normal")
}
  1. A. 0
  2. B. 30
  3. C. 29.9
  4. D. 29

Question 9 of 10

For flag = false, what is displayed?

IF (flag)
{
  DISPLAY ("yes")
}
ELSE
{
  DISPLAY ("no")
}
  1. A. true
  2. B. yes
  3. C. no
  4. D. flag

Question 10 of 10

Both branches look like valid weather advice. With wind = 20, what is displayed?

IF (wind >= 20)
{
  DISPLAY ("secure outdoor items")
}
ELSE
{
  DISPLAY ("mild wind")
}
  1. A. mild wind
  2. B. secure outdoor itemsmild wind
  3. C. 20
  4. D. secure outdoor items