Computer Science & C Programming


Go further: programs & sub-programs

  1. The preceding program/algorithm computes factorial(n=4) and can be represented as follow:

And this representation can be specified by a C program as:


int fact(int n) { // sub-program declaration
  int r;
  ...
  return r;
}

A program with no parameter and no result (void) such as the main program will be declared as follow:


void main() {
  ...
}

1 - 6