Your first C program should be small enough that you can explain every line. Begin with a greeting, change one thing at a time, and use the compiler’s feedback to connect source code with behavior. You do not need an account or a desktop installation to follow this guide in Circuit.
Start with a complete program
Open the compiler and create a program named greeting.c. A .c extension identifies C source, but a filename does not make text valid C. Replace the starter text with the complete example below. Preserve the punctuation even if it seems unfamiliar: braces group the function body, quotation marks delimit text, and semicolons end statements.
The first line includes the standard input/output declarations. It lets the compiler check a call to printf against the function’s declared type. The header is not the function implementation itself. The toolchain connects your call to the library implementation later.
#include <stdio.h>
int main(void) {
printf("Hello, Circuit!\n");
return 0;
}Understand where execution starts
main is the entry function in this hosted C environment. int says that it returns an integer status, and void inside the parentheses says that this version takes no parameters. Execution enters the braces, performs the printf call, and reaches return. A return value of zero conventionally reports success to the environment.
The characters \n inside the string form an escape sequence for a newline. They are not printed as a backslash and the letter n. Spaces inside the quotation marks are output; indentation outside them is for people reading the source. Consistent indentation makes nested code much easier to understand later.
Compile, then observe the terminal
Press Run code or Ctrl/Cmd + Enter. Circuit downloads its compiler assets on the first run, compiles C into WebAssembly in a worker, and executes the result locally. The terminal reports compilation problems or displays the program’s output and final status. A first run may take longer than later runs because of the download.
You should see Hello, Circuit! followed by a successful exit. The terminal’s status is separate from text written by your program. Do not add status messages to your source just to match the surrounding interface. If the compiler rejects the source, there is no new executable to run; fix that diagnostic first.
Make a controlled change
Change the greeting to your own short sentence and run again. Next add a second printf statement before return. Predict whether its text starts on a new line, then test that prediction. Removing the first \n joins the two pieces of output onto one line; putting a newline back separates them.
Try storing a small integer in a variable and printing it with printf("Score: %d\n", score). The %d conversion expects an int value as the next argument. Do not put score inside the quotation marks unless you want the literal word. This distinction between text and evaluated expressions appears throughout C.
Read an error without starting over
Temporarily remove the semicolon after printf. The compiler will usually indicate where a semicolon was expected, sometimes on the following line. Read the earliest diagnostic, inspect the line above it as well, restore the punctuation, and compile again. One missing token can produce several later messages that disappear together.
An error prevents a build; a warning identifies something worth checking even when compilation succeeds. Neither is the same as a wrong answer from a valid program. For example, printing 2 + 2 while labeling it as multiplication compiles correctly but contains a logic mistake. Compare actual output with a prediction, not just the success badge.
Keep your work and choose the next exercise
Circuit autosaves programs in this browser’s IndexedDB storage. Wait for Saved locally before leaving. Download a .c file for an individual program, or Export all for a library backup. Closing a tab only closes that editor view; deleting a program removes the saved entry. A different browser, device, or site domain has a separate library.
Before moving on, explain the header, main, printf, newline, and return in your own words. Then open Add Two Numbers to learn input. Keep the greeting as a working reference and create a new program for experiments. Small independent examples make it easier to identify which new concept caused a problem.