An example
/* hello.c Jeff Shallit 3/29/89 */
/* This program just print some things and quits.
* It illustrates the structure of C programs, and
* how to run the compiler
*/
#include <stdio.h>
main()
{
int n;................./* an integer variable
*/
....printf("Hello, world\n");
....n = 10;
....printf("The value of n is %d\n",
n);
}
Comments delimited by /* and */
#include <stdio.h> reads
the header (interface) file for the standard I/O
....library.
Parameters to procedures enclosed in parens, main() expects no arguments.
Every program must have a procedure called main.
Procedure body delimited by {and }.
Some special characters: \n -- newline, \t --
tab, \0 -- end of string,\f
....-- form feed.
Format specifications introduced by %, one for each additional
argument to
....printf. Some useful
formats: %d -- decimal integer, %s -- string,
....%c -- character,
%f -- floating-point, %%
-- the character % itself.