As explained in the editing help, in MarkDown you can achieve preformatted text by using four spaces intendation.
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 Ctrl+K.
To test this I have taken an example of for cycle in C from this website. (Basically a random site that I got after searching for "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? Here is a screenshot which I copied from that post: