modulus operator %
The % operator is the same as the Fortran mod function, returning the remainder after integer division.
This provides an easy way to test whether an integer variable is even or odd:
C provides an even faster way to do this - test whether the lowest bit is 0 or 1:
the sizeof operator
This takes a variable or array as an argument, and returns the number of bytes it
contains. For instance, to obtain enough space for a double precision array of
length of 10, one would call
prefix and postfix operations . . .
Performing an operation on a variable, and saving the result in the same variable, happens so often that C has a shorthand for it. The following pairs of statements are equivalent:
i = i + 1;
j = j + 2;
a = a / 2.;
There is no reason to use this, except for brevity.
and side effects
Side effects are when a single line does more than one thing. They are a source
of pride for people who code too much C, but are avoided by the rest of us, who want to
write clear code. As an example, consider
Fortran has the a**b function, which raises a to the power b. C does not support this as a fundamental form of operation. Rather, math.h includes the pow function, which would be coded as pow(a,b).