Learn C
#include "variablesdatatypes/literals.h"

Literals in C

#concept

A literal is a value written directly in source: 42, 3.14, 'A', "hello", and (since C23 / stdbool.h) true/false. Integers default to int with U/L/LL suffixes for unsigned/long/long-long; decimals default to double with f/F for float and l/L for long double; 0x marks hex, 0b (C23, or GNU extension) binary, leading 0 octal.

Character literals are ints in C (unlike C++ where 'A' is char!) — sizeof('A') == sizeof(int). String literals are read-only char arrays with an implicit null terminator, and adjacent literals concatenate ("foo" "bar" becomes "foobar"), handy for splitting long strings across lines.

#how it works
1

Integer suffixes and bases

42U unsigned, 42L long, 42LL long long; 0xFF hex, 017 octal, 0b1010 binary (C23/GNU) — same values, convenient spellings.

2

Floating defaults to double

3.14 is double; 3.14f is float. Assigning bare decimals to float narrows and may warn.

3

Char literals are ints

In C, 'A' has type int (value 65) — a classic interview trap distinguishing C from C++.

4

Strings concatenate and terminate

"foo" "bar" pastes into "foobar" at compile time; every literal carries a hidden trailing '\0'.

#example
#include <stdio.h>
 
int main(void) {
int hex = 0x2A;
long long big = 3000000000LL;
float f = 2.5f;
printf("%d, %lld, %.1f\n", hex, big, f);
return 0;
}
Output
42, 3000000000, 2.5
10x2A is hex for 42 — stored as a plain int, printed with %d.
23 billion needs long long; the LL suffix plus %lld keep type and specifier aligned.
32.5f is genuinely float, matching f with no narrowing.
#use cases
Bit masks and flags written as 0xFF hex instead of decimals
LL suffixes on large constants (timestamps, byte counts)
The f suffix wherever a literal feeds a float
Splitting long format strings across lines via implicit concatenation

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in C yourself — building beats watching.