
Getting Started
To get started with computer programming, you will need to choose integrated development environment (IDE). An IDE is where you will write your code, compile it into a program, and test your program. C is a lower level language, hence, there are lots of complicated configrations to work through.

To simplify the learning process, I recommend choosing a web-based IDE, like OnlineGDB, where everything is preconfigured and ready to go. You can even register an account and save your codes. If you prefer to work locally, you can install Visual Studio Code and the GNU Compiler Collection (GCC).

- Select C as the programming language
- Compile and run the code
- Change the console position to the side (optional)

Congrats, you just wrote your first C program!
If everything went as expected, the program should print “Hello World” on the consolue output. The codes might seem confusing at first, but no worries, we will go through them in the follow section.
Structure of a C Program
Let’s take a look at our first program. Let’s ignore the yellow text in between /*
and */
for now. Those are called comments, they are notes written for human and are not parts of the program.
#include <stdio.h>
int main()
{
printf("Hello World");
return 0;
}
The first line of the program, #include <stdio.h>
is how we include a library with the program. Libraries are like toolboxes that hold tools (aka functions) that we can use to build our program. In this case, we are using the Standard Input and Output Library (stdio), which contain functions that we can use to print message to the screen and also receive inputs from the user.
The next thing in our program is where we define the main function. Everything in between the curly brackets { }
are consider part of the main function. Inside, we will put other functions (or commands if that sounds better) to make our program “to things”. The functions get executed sequentially in order.
int main()
{
// This is where you will write your program
// Btw, this is a comment, as the line is started with //
}
Let’s take a look at what’s inside our main function. The first command we get is printf("Hello World");
. The printf
function stands for print format and is used to print text to the screen. The actual message to be printed goes inside the parentheses ( )
and is surrounded by double quotes " "
. In this case, since we are printing Hello World, the printf function input should be "Hello World"
. Every function that’s going to be executef must be ended with a semicolon ;
Finally, we see that the program ends with return 0;
. This simply output the error code 0 when the program finish running. Error code 0 means that the program ran successfully and there’s no error.
Great, now let’s try to print another line to the console, how about your name? Before looking at the solution, let’s give it a try yourself!
#include <stdio.h>
int main()
{
printf("Hello World!\n");
printf("My name is Billy Hau!");
return 0;
}
Notice that I have a special character '\n'
after Hello World? What happens if that’s not there? Well, give it a try and see for yourself. It’s best to learn computer science by tinkering, breaking and fixing things.
Debug Your Code
If the program failed to run, you had probably made a mistake somewhere. Usually, the compiler is smart enough to point you to your error. So let’s take a look at the image below. It said that main.c:6:36: error: expected ‘;’ before ‘return’
.
This might seem intimidating, but no worries, it simply mean that the error occurs in the fiel main.c line #6 at the 36th character. It is expecting a semicolon ;
but couldn’t find it.

Exercise
- Write a program that print your profile information onto the screen. With information like First Name, Last Name, Gender, Age, Phone Number, and Email.
Data Types and Variables
Primitive Data Types
A computer’s core functionality is to process data. Therefore, it is important to learn about the different types of data that we can store in memory. When talking about data, the first things that come into your mind are probably videos, musics, Word and Excel documents. While they are definitely data, those are complex data that are built from the fundamental building blocks called primitive data type. The table below listed the different primitive data type supported in the C programming language.
DATA TYPE | NAME | EXAMPLE |
int | Integer | 28 |
char | Character | ‘a’ |
float | Floating-Points Number | 3.141593 |
double | Double Precision Floating-Points Number | 3.141592653589793 |
The int
data type hold integers, which are whole numbers. The char
data type hold a single alphanumeric and special character from the ASCII table. The float
data type hold a decimal number with aronud 7 decimal digits. If you need more precision, the double
data type is essentially double the size of a float, and can hold a number with up to 15 decimal places!
It is important to use correct data type to hold the correct data. If you put a float
value inside an i
nt
memory slot, you will usually end up loosing the decimal places without warning.
Variables
User Inputs and Outputs
coming soon…
Mathematical Operators
coming soon…
The Math Library
coming soon…
User-Defined Function
coming soon…
User-Defined Library
coming soon…
Comparison Operators
coming soon…
Conditionals
coming soon…
Loops
coming soon…
Arrays
coming soon…
C Strings
coming soon…
Memory, Addresses and Pointers
coming soon…