Example Program in C

In most examples we will use the latest C standard (C99) which brings the C syntax even closer to C++ and Java . File simple.c:

#include <stdio.h>   // this imports a definition file (a header).

double value;    // some variable definition on global scope

/* this is another form of comment. Here we use it to describe both 
   parameters of main: argc is the number of
   commandline parameters given to the program. 
  **argv is an array of pointers pointing to the parameter values. 
   The program can use it to access its parameters.  */

int main(int argc, char **argv)   // note the return type of main: 0 means ok
{
    int local=0;
    value = 0.42;       // value is defined outside of this block

    // a function call into the standard C library. 
    // Note that the number of parameters is variable!!

    printf("local = %d value = %f\n", local, value);  
    return 0;          // tells whoever started the program that all is well
}