You are working on a program that needs to perform different actions based on the day of the week. Which control statement would be most appropriate to use?

  • for
  • if-else
  • switch
  • while
The correct answer is B) switch. The switch statement is ideal for situations where you want to execute different code blocks based on the value of a variable (in this case, the day of the week).
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *