As explained in the [editing help](https://mathoverflow.net/editing-help), in [MarkDown](https://meta.mathoverflow.net/tags/markdown/info) you can achieve preformatted text by using four spaces indentation. To achieve this after typing (or copy pasting) the code, simply select the relevant part and the click on the *code button* in the editor (between blockquote and insert image) or press <kbd>Ctrl</kbd>+<kbd>K</kbd>. To test this I have taken an example of for cycle in C [from this website](https://beginnersbook.com/2014/01/c-for-loop/). (Basically a random site that I got after searching for "[for cycle c example](https://www.google.com/search?q=for+cycle+c+example)".) #include <stdio.h> int main() { int i; for (i=1; i<=3; i++) { printf("%d\n", i); } return 0; } You can find much more detailed information in the FAQ post: [How do I format my code blocks?](https://meta.stackexchange.com/q/22186) Here is a screenshot which I copied from that post: ![Code blocking icon properly highlighted][2] [2]: //i.sstatic.net/vCW2k.png