Skip to content
Circuit

Hello World in C

Basic Programs

Print a greeting and learn the smallest useful structure of a C program.

Complete program

#include <stdio.h>

int main(void) {
    printf("Hello, world!\n");
    return 0;
}

Try in Circuit →

Opens a new program without replacing your saved code. Press Run when you are ready.

How it works

The stdio.h header declares printf. Execution begins in main; the call writes a string to standard output. The escaped \n ends the line, and return 0 reports successful completion.

Change only the words inside the quotation marks and run again. Then remove the semicolon to see how a compiler diagnostic points to a syntax error. Restore it before continuing.

Expected output

Hello, world!

Concepts to practice

  • Headers
  • main
  • String literals
  • Exit status

Predict a different input or change one value, then compare the result with your prediction. Keep changes within the documented bounds and read warnings before trusting an answer.