C Introduction
Meet C by counting survey markers, then follow the route from source text to a running program.
How it works
C describes operations on values and storage. A compiler translates source into a program for a particular target. You will use that control to build small field-survey tools: counting observations, checking readings and saving a report. This is hosted C, where a runtime starts main and supplies standard streams; a microcontroller can have a different startup contract. You need no previous programming, but you should be comfortable saving a plain-text file and opening a terminal. Start with one file so you can connect every displayed result to an instruction.
Run it locally
Use a hosted C17 compiler in a separate lab folder. The command assumes a driver named cc; substitute gcc, clang or zig cc as appropriate. C does not currently run in Bhylu’s browser playground. Apache, PHP and MySQL are not needed for these C programs.
cc -std=c17 -Wall -Wextra -Wpedantic -Werror intro.c -o lessonOn Windows, use -o lesson.exe and run .\lesson.exe in PowerShell. On Unix-like systems run ./lesson. Math-library linking differs by toolchain; GCC on many Unix systems needs -lm after the source.
Download the complete C source. File-writing labs must run in an empty private directory, away from existing reports.
Example
#include <stdio.h>
int main(void) {
int markers = 6;
int spare = 2;
printf("Survey markers: %d\n", markers + spare);
return 0;
}
Expected result
Survey markers: 8
The include supplies declarations for the standard output library. main is the entry point of this hosted program. The two objects hold counts; the expression adds their values before printf formats the result. A successful return from main becomes an exit status for the caller. This example uses no database, web server or browser.
For language and library rules, consult the WG14 C working group and its public C11 committee draft, which describes the core facilities used here; C17 incorporates corrections. Check your compiler and runtime documentation for implementation details.