else
that contains no statement can be removed{}
of a block containing a single statement can be removedreturn
can be substituted to a variableint abs(int x) {
if (x<0) return -x;
return x;
}
Exercices:
a. How to simply the following code:
int i;
int r;
i=1;
r=1;
loop:
r=r*i;
i=i+1;
if (i<=4) { goto loop; } else {}
b. How to transform the preceding instructions into a program factorial(n)
?
c. How to transform exercice 1 from the preceding chapter into a sub-program ?