Lesson 1 · 1 of 20
Hello, world · C
Write your first C program: include stdio.h, create the main function and print text on the screen with printf, \n and \t.

Every C program starts with the libraries it needs. #include <stdio.h> brings in the standard input and output functions, including `printf`, which writes text on the screen. Lines starting with // are comments: the compiler ignores them and they are there to explain the code.
The program always starts running in the `main` function. int main(void) says that main takes nothing and returns a whole number; its code goes between braces { } and every statement ends with a semicolon ;.
printf writes the text exactly as given, without starting a new line. That is why "One, ", "two, " and "three!\n" end up together on one line: only `\n` moves to the next one. In the same way, `\t` inserts a tab for simple columns and \" puts quotes inside the text.
return 0; ends main and tells the system that everything went well. In DMarlon Studio, C is written in the Console target: press F9 and the program is compiled and run in one click, with the output right there.
Code · main.c
// stdio.h brings printf, which writes text on the screen.#include <stdio.h>// Every C program starts running in main.int main(void) { printf("Hello, world!\n"); printf("Welcome to the C course.\n"); // \n starts a new line; without it, the text carries on. printf("One, "); printf("two, "); printf("three!\n"); // \t inserts a tab, handy for simple columns. printf("Day\tWeather\n"); printf("Mon\tSunny\n"); printf("Tue\tRainy\n"); // \" writes quotes inside the text. printf("She said \"C is fast\".\n"); return 0; // 0 tells the system that all went well}Output · cc main.c -o main && ./main
Hello, world! Welcome to the C course. One, two, three! Day Weather Mon Sunny Tue Rainy She said "C is fast".
Key points
#include <stdio.h>gives youprintf.- The program starts in
int main(void). - Every statement ends with
;. printfdoes not start a new line: add\n.return 0;means the program finished fine.
Exercise
Add three more days (Wed, Thu, Fri) with their weather at the end, lined up with \t, and a goodbye line.