Your First C Program
Read a complete C program
You have printed the workshop's sign. Now read the same structure in a library shelf message so you can recognize what stays the same when the wording changes.
#include <stdio.h>
int main(void) {
printf("Library open\n");
return 0;
}
Start the execution trace at main, not at the include. The header gives the compiler a declaration for printf during the build. At run time, printf sends Library open and a newline to standard output, the program's usual text output stream. The console shows that stream.
The braces group main's body. Here the call and the return statement each end with a semicolon. The closing brace does not need one. return 0; reports successful completion without adding text to the console.
Two calls, two lines
#include <stdio.h>
int main(void) {
printf("Shelf A\n");
printf("Shelf B\n");
return 0;
}
The first call prints Shelf A, then \n moves to the next line. The second prints Shelf B. A source-code line break between two calls does not itself create an output line break: the \n in the string does that.
These Run blocks are fixed examples. To experiment, copy a complete example into a local main.c if you have a compiler, or use an editable exercise later. Without the first \n, the second program would print Shelf AShelf B on one line.
If a build fails
A comment such as /* shelf label */ is ignored by the compiler. Punctuation outside a comment still matters. If you accidentally delete a semicolon after printf, the compiler reports an error rather than running the incomplete new program. Read the first error, check that line and the line above it, restore the semicolon, and rebuild.
For optional local practice, gcc -std=c11 -Wall -Wextra main.c -o main builds the file; ./main runs it on a Unix-like system. You do not need this setup to continue with the course exercises.