"Old school" C (aka K&R)
if (boolean expression) {
code;
code;
}
else {
code;
code;
code;
}
I've always used this, and like it visually because the closing braces line up with the opening "if". Saves lines, too.
I also like
if (bool exp) code;
because it saves lines (you see more on the screen at once... too much white space can be as bad as too little.)
And finally, for similar reasons, I will also use
if (b exp) code;
else code;
or even sometimes
if (b exp) code; else code;
Sometimes I'll vary it with
if (b exp)
longer-line-of-code;
else code;
if it looks more balanced (and of course, just to annoy people like Jante
And to generalise, I delight in using
for (;;) code;
and
while (bool exp)
code;
when it suits.
As an odd inconsistency (but also found in K&R) is the use of braces when declaring functions:
int myFunction(int avar)
{
/* implementation in here */
}
Although it strikes me as stylistically a bit inconsistent, I've also decided I kind of like bringing the opening brace onto the next line for function declarations, rather than at the end of the line, as in a control block.
In short: Good enough for Dennis, good enough for me.