Now let's take a closer look at the word order in interrogative sentences with a question word. There are rules here too, but they are quite simple.
Basic rule
When you start a question with a question word, it is usually followed by a verb and then the subject. Let's look at some examples of this:
Was machst du? (What are you doing?)
Here "Was" is the question word, "machst" is the verb, and "du" is the subject.
Wo wohnst du? (Where do you live?)
Here "Wo" is the question word, "wohnst" is the verb, and "du" is the subject.
More examples
Here are a few more examples to better understand how this works:
Wann kommst du? (When will you come?)
"Wann" is the question word, "kommst" is the verb, and "du" is the subject.
Warum lernst du Deutsch? (Why are you learning German?)
"Warum" is the question word, "lernst" is the verb, and "du" is the subject.
Questions with modal verbs
If there is a modal verb in the question (e.g. können, müssen, wollen), the word order remains the same, but the verb in the infinitive goes to the end of the sentence:
Was kannst du spielen? (What can you play?)
"Was" is the question word, "kannst" is the modal verb, "du" is the subject, and "spielen" is the infinitive.
Wann musst du gehen? (When do you have to leave?)
"Wann" is the question word, "musst" is the modal verb, "du" is the subject, and "gehen" is the infinitive.
A little practice
Now let's put some questions together:
Wie heißt du? (What's your name?)
Was isst du gerne? (What do you like to eat?)
Woher kommst du? (Where are you from?)
Wie lange bleibst du? (How long will you stay?)