Guide
Syntax, pointers, memory, structs and file I/O - the systems-language
foundation
Complete Study Guide | Key Concepts | Examples | Practice Questions
, 1. C Basics and Program Structure
C is a compiled, procedural language close to the hardware. Every program starts at main(); headers declare
library functions.
#include <stdio.h>
int main(void) {
int age = 21;
float pi = 3.14f;
char grade = 'A';
printf("Age: %d, Pi: %.2f, Grade: %c\n", age, pi, grade);
return 0;
}
// compile: gcc program.c -o program run: ./program
- Format specifiers: %d int, %f float, %c char, %s string, %p pointer, %x hex.
- Preprocessor lines (#include, #define) run before compilation.
- C is statically typed: declare every variable with its type.
- Statements end with semicolons; braces group blocks.
Page 1