Question about syntax/form

I am just curious which of the following would (generally) be considered better form. I have seen examples of code written both ways, but am not experienced enough to know which is more readable.

1
2
3
while (i<50) {
     cout << i*2;
}


or

1
2
3
4
while (i<50)
{
     cout << i*2;
}
It's completely personal preference and highly controversial. The Java people will strangle you for not using #1, but in C/C++ I recommend #2 (and still people will argue).

Just figure out which one makes it easier for you to read and write code and stick with it, but be prepared to use a different style if a group project requires it.
Is there a reason method #1 is preferred by Java programmers? Java is actually a language I am interested in learning at some point and I have no personal preference, so #1 it is.
It has to do with Oracle's styleguide.
Topic archived. No new replies allowed.