Before you create a code question, it might be helpful to understand the general outline of an exam question. We explain that in the Creating a question article.
From the Designer page, click on new question. From the top right corner, click on the Add new question button.
From the blocks bar, click on the Code block.
Now you need to select the programming language you're going to use. You can select it from the dropdown menu.
Type your code in the code editor.
As an optional step, you can enable the Highlight code option. This will color the code in the code editor.
Click on the Save changes button and you will see the question in the questions list.
You can use the highlight with different kinds of questions. For example, you can disable highlighting and ask students to find mistakes in the syntax of the code.