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
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:
Let us look at another printing statement:
- 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.
The output of this would be: