QUESTION IMAGE
Question
question: 4
you need to write a program that has karel move if the front is clear, but if it isnt clear, karel will do nothing.
which control structure do you need to use?
for loop
while loop
if statement
if/else statement
none of these
An If Statement executes a block of code if a condition is true. In this case, the condition is "front is clear" and the action is "move". Since there's no action specified for when the condition is false (Karel does nothing), an If Statement (not If/Else which would have an action for false) is appropriate. For Loop and While Loop are for repetitive execution, which isn't the case here.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
C. If Statement