Advertisement

Example C Program

/*
 File: hello.c
 Description: Prints a greeting to stdout.
 Author: Douglas C. Schmidt <schmidt@uci.edu>
 */
#include <stdio.h>

int main (void)  /* execution starts in main */
{
    printf ("Hello world.\n");
    return 0; 
}

    All C programs must have a function in it called main

    Execution starts in function main

    C is case sensitive!

    Comments start with /* and end with */.  Comments may span over many lines.

    C is a “free format” language.

    The #include <stdio.h> statement instructs the C compiler to insert the entire contents of file stdio.h in its place and compile the resulting file.