Thuta Learning
BasicProgrammingbeginner

Syntax

Relax. We'll talk through this in plain words — no textbook voice.

The basic shape of a C program is: include the header files, write a main() function, and end each statement with a semicolon. C is strict about grammar, so you need to be extra careful with brackets, semicolons, and quotes.

c
#include <stdio.h>

int main() {
  printf("Hello World!");
  return 0;
}

#include brings in a library, int main() is the program's main function, { } marks a code block, printf() prints output, and ; tells the compiler a statement has ended.

You should see
Hello World!

Info

printf("Hello World!") — the text inside needs to be written with double quotes. Use single quotes for a single character, and double quotes for a string/text.

Easy traps

  • Forgetting a semicolon, leaving a quote unclosed, or missing the closing brace } are the most common errors beginners run into.
Syntax | Thuta Learning