Next: Variables
Up: Basic C Programming
Previous: Basic C Programming
A C program basically has the following form:
- Preprocessor Commands
- Type definitions
- Function prototypes - declare function types and variables passed to
function.
- Variables
- Functions
We must have a main() function.
A function has the form:

If the type definition is omitted C assumes that function returns an integer type. NOTE: This can be a source of problems in a program.
So returning to our first C program:

NOTE:
- C requires a semicolon at the end of every statement.
- printf is a standard C function - called from main.
-
n signifies newline. Formatted output - more later.
- exit() is also a standard function that causes the program to
terminate. Strictly speaking it is not needed here as it is the last line of
main() and the program will terminate anyway.
Let us look at another printing statement:
printf(``.
n.1
n..2
n...3
n'');
The output of this would be:
