Lesson 5 / 36
Variables
Named, typed pieces of memory.
Declare with a type
You must state the type. Uninitialised variables hold garbage.
int age = 25;
float price = 9.99f;
char grade = 'A';
int score; // unknown until assigned
score = 100;Constants
const double PI = 3.14159; cannot be reassigned. #define MAX 50 is a compile-time text swap.
Printing them
printf uses format specifiers: %d int, %f float, %c char, %s string. printf("n = %d\n", n);