Chapter 2: Understanding the Basics

Let's take a closer look at the key parts of the "Hello World" program. Here's the code:

#include <stdio.h>

int main() { printf("Hello World\n"); return 0; } #include <stdio.h>

This line tells the program to include the "Standard Input/Output" library, which is necessary to use functions like printf. Without it, the program wouldn't know how to display text on the screen.

int main()

This is the main function where the program starts. Every C program must have a main function, as it acts as the entry point for execution.

printf("Hello World\n");

The printf function prints the text "Hello World" to the screen. The at the end creates a new line, ensuring the text appears cleanly.

return 0;

This line tells the operating system that the program executed successfully. The value 0 is a standard way of indicating that everything went as planned.

Last updated