Computer Science & C Programming


Go further: extending C syntax

  1. The loop is particular in the sense it is based on an iterator i and the number of computations is known. In such a case, it is convenient to use a finite loop for:
int r=1;
for (int i=1; i<=n; i++)
  r *= i; 
return r;

6 - 6