Constants & Limits in C

From the C cheat sheet · Variables & Types · verified Jul 2026

Constants & Limits

const, enums, and type limits.

c
// Quick Reference
const double PI = 3.14159;
#define MAX 100
#include <limits.h>
INT_MAX;  // largest int
💡 const gives a typed, scoped constant; #define is a raw preprocessor text swap.
⚡ <limits.h> (INT_MAX, CHAR_BIT) and <float.h> (DBL_MAX) expose type ranges.
📌 Enums are the idiomatic way to name related integer constants.
🟢 Prefer const or enum over #define for values - they respect scope and types.
constenumlimits

More C tasks

Back to the full C cheat sheet