You should see a button which looks like this </> and which will add the code format automatically. Alternatively, you could just wrap your code manually into three backticks ```.
If you click on the edit button in your post, you will see, what I’ve added