1.1 Hello World and Compilation
A program is a set of instructions that asks a computer to solve a problem. A beginner-friendly way to think about programming is this: computers do not understand natural human language. Even a request as simple as “calculate 1 + 2” must be written as precise executable steps.
At the lowest level, computers process binary information represented with 0 and 1. A programming language helps turn human intent into structured instructions. You write source code, and the C compiler checks that code, converts it into a program the computer can run, and reports errors when the syntax does not follow C’s rules.
Common mainstream programming languages include:
- Python: beginner-friendly and widely used for data analysis, AI, automation, and web backends.
- C: closer to low-level computer systems, often used for operating systems, embedded systems, and performance-sensitive programs.
- C++: extends C with more abstraction, and is common in game engines, high-performance computing, and large software systems.
- Java: widely used in enterprise backends, Android development, and large cross-platform systems.
- JavaScript / TypeScript: central to web frontends, and also used for backend and full-stack development.
- Go, Rust, and C#: common in cloud services, systems programming, game development, and enterprise applications.
These languages differ in syntax, use cases, and learning curve, but they share the same basic goal: turning human ideas into precise instructions a computer can execute.
What is a program?
Most programs combine four basic kinds of action:
- Input: receive data from a keyboard, file, network, or another source.
- Processing: calculate, compare, transform, or store data.
- Output: display a result, write a file, or send data somewhere else.
- Control flow: decide what runs first, what repeats, and what only runs when a condition is true.
When learning C, you do not need to master every syntax rule immediately. First build this mental model: a program is a clear sequence of steps, and the computer follows those steps exactly.
Flowchart
A flowchart is a visual way to describe program steps before writing code.
The flowchart below describes how to sum integers from 1 to 100. Notice the diamond-shaped node: it represents a decision. If the condition is true, the program keeps adding; if it is false, the program prints the result and stops.
Sum integers from 1 to 100
A standard flowchart uses terminators for start/end, rectangles for processes, and a diamond for decisions.
In code, this becomes initialization, a loop condition, accumulation, variable update, and final output.
#include <stdio.h>
int main(void) {
int i = 1;
int total = 0;
while (i <= 100) {
total = total + i;
i = i + 1;
}
printf("%d\n", total);
return 0;
}Your first C program
Hello World is usually the first program in a new language. Its job is simple: print a piece of text to the screen.
#include <stdio.h>
int main(void) {
printf("Hello World!\n");
return 0;
}Output:
Hello World!There are five details to notice right away:
#include <stdio.h>brings in the standard input/output declarations.mainis usually the entry function of a C program.- The braces
{}group the statements that belong to the function. printf()prints text, and\ninside the string means a newline.return 0;signals that the program finished normally.
You can read the middle line as: “call printf, and display the string Hello World! on the screen.”
Running C code
Many beginners write C in an IDE that runs with one click, such as Code::Blocks, CLion, Visual Studio, VS Code with the C/C++ extension, Xcode on macOS, or an online judge / teaching environment. In these tools you usually create a C source file, click Run or Build, and see the result in an output panel.
If you use a terminal, save the file as hello.c, then compile and run it with gcc:
gcc -Wall hello.c -o hello
./helloIn Windows PowerShell, running the program in the current directory usually looks like this:
.\hello.exeLater lessons focus on C syntax and problem solving, and assume you already have an IDE, teaching platform, or other one-click setup to run the examples.
Hello World in other languages
Different languages use different syntax, but the purpose is the same: display text on the screen. Comparing these examples shows which structures C spells out explicitly.
print("Hello World!")#include <iostream>
using namespace std;
int main() {
cout << "Hello World!" << endl;
return 0;
}public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}C, C++, and Java make the program entry point, imports, classes, or function structure more explicit. C also makes the compile step part of your daily workflow, which helps you see how source code becomes a runnable program.
Comments
Comments are notes for humans. They are not executed as program instructions. Use comments to explain intent, record context, or mark a point that future readers should understand.
Common C comment styles:
- Single-line comments start with
//. - Multi-line comments are wrapped in
/* ... */.
printf("Hello World!\n"); // display "Hello World!"More comments are not always better. For beginners, a good rule is to comment why something is done, not merely repeat what the line already says.