Introduction to Algorithms and Programming

Reading source code

Reading source code to learn programming

The habit of reading source code helps programmers to:

In professional environments, reading source code is often required to:

C is a procedural language

The main() function is required for all C programs.

Preprocessor directives

The preprocessor directive is used to include the source code from the stdio.h header file into the current program.


C programs use 2 types of statements.

Function calls and input parameters

Function calls require a pair of parentheses after the name of the function.

Source code comments

Comments start with /* and continue until it reaches a matching */ end.

Do not use C++, Java or PHP style comments, which use a double forward slash at the start of comments.
// Do NOT use comments in this style
// They reduce portability between C compilers

When reading the source code, pay attention to the usage of curly braces, parentheses and semicolons in the programs.

Steps to create C programs

Reserved keywords in the C language

Reserved keywords may not be used as names of functions or data variables.