The main() Function of C
C programs are composed of
which are vaguely analogous to recipes.
A function can take inputs (like ingredients) and it can
produce outputs (like a cake).
(Don't worry, we won't keep up this analogy for long.)
Now let's return to our "Hello World" program.
It's only function was:
For now, it will suffice to notice only a few things about
Every C program must have a function called
Even though there are more precise ways of defining
, it is enough in simple examples to just follow the
name of the function (
) with an empty set of parentheses.
The actions that are to make up the program are listed within
a balanced set of braces that follow the line declaring main.
While the placement of the braces is not defined by the C
language, we will consistently follow this style and you are
encouraged to do the same.
Joe Inexperienced Hacker tried to write "Hello World" this way:
In what ways did he fail to produce a valid C program?
(Check all the applicable options.)