Example 1 — Constants for a circle
The same macro is used in an array size and a formula.
#include <stdio.h>
#define PI 3.14159
#define BUFFER_SIZE 64
int main(void) {
char buf[BUFFER_SIZE];
double r = 5.0;
printf("size=%zu area=%.2f\n", sizeof buf, PI * r * r);
return 0;
} How It Works
BUFFER_SIZEbecomes64, sobufhas 64 bytes.PI * r * ris3.14159 * 5 * 5 = 78.53975.%.2frounds to78.54.
