Computer Science & C Programming


Go further: programs & sub-programs

  1. A sub-program is then called with its name and values for the parameters, e.g. factorial(4).
  2. There exists libraries (e.g. stdio.h) of already defined sub-programs with in particular the printf function to display texts pn screen:
#include<stdio.h>

void main() {
  printf("%s","welcome to you !");
}

This function can serve to display values as illustrated below:


#include<stdio.h>

int factorial(int x) { ... }

void main() {
  int v;
  v = factorial(4);
  printf("%i",v);
}

Now, the code can be written with any text editor and compiled (i.e. translated into processor's instructions) with any C compiler as explained here.


2 - 6