Chapter 2: Hello World

Chapter 2: Hello World

In this lesson, we will be working towards developing one of the most famous programs ever written, the simple Hello World program.

The Hello World program, despite its fame, is not as scary to compute as you may think. Rather, it is just a computer program that outputs or displays the message “Hello World”. It is a tradition across all programming languages and learning books alike to have the first program written as “Hello World”, a tradition that began with C in 1978.

Before we write our program, however, it is important that you are equipped with a basic knowledge of ‘Boolean algebra’, which is a type of math that deals with bits (1s and 0s) instead of numbers. This may sound odd, or irrelevant but is important to understand this concept when programming.

In Boolean algebra, a binary value of 1 is interpreted to mean “true” and a binary value of 0 means “false.” This means Boolean algebra can deal in true and false statements, mathematically! Pretty impressive.

For this, we use conditions such as NOT, AND and OR
0 NOT 1 is true because 0 is NOT the same as 1;
0 AND 1 is false since 0 AND 1 are not the same;
0 OR 1 is true because one of the statements is one.

This is a very simple introduction to Boolean algebra, but it will help you understand a little more of how programming languages are structured. This kind of logic is needed because based on this, we can set up little circuits that either have a charge or not. From here we can build an entire computer! This is fundamentally how all computers work at a very basic level. Simply by representing true or false statements with “on” or “off”, translated as 1 or 0.

Now, lets move onto a very simple program named hello world.

Writing your First Code:

Lets begin!

#include <stdio.h> 

int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;

Already here we have displayed some complex looking code, but this code is very simple, and just prints the words “Hello World” on the screen.

The first thing is the #include <stdio.h>. This simply includes a header file for our compiler to access, in order to perform more complex functions, such as printing using the printf() function.

From here, we open up the main function. The main function is the point at which the execution of a program is started. We make sure to put all the code we wish to run inside this main function. Then we use the print function to print the words ‘Hello, World!’ onto the screen. When we place text into a quotation mark, ” ” like this, we refer to it as a string, a string of characters. Finally comes the return statement. That simple says to the main function, it can stop, and it has reached the end in this context.

All of the functions and methods we have used here are a little more complex than we have detailed here, but well-done everyone on completing your very first lesson on C, and writing your first-ever program!

Exercise: Use C to print your first name and second name onto the screen, be sure to let me know how you get on either via messages on the site or via the Facebook page for Devoke Studio! I love to hear about your progress!

This course is provided for free, as we at Devoke believe all education should be. However, if you enjoy the course, we are always grateful for support and donations to Patreon to ensure we can continue providing resources for free.

Please Login to read or post comments