Actions

EmSys

CCoding Style - Use Idioms for consistency

From EdWiki

Use Idioms for consistency

Like natural languages, programming languages have idioms. A central part of learning any language is developing a familiarity with its idioms.

1

i = 0;
While( i <=  n–1 )
    array[i++] = 1.0;

2

for( i = 0; i < n; )
    array[i++] = 1.0;

3

for( i = n; --i; i >= 0 )
    array[i] = 1.0

All of the above are correct, but the idiomatic form is like this:

for( i = 0; i < n; i++ )
    array[i] = 1.0;