short Short integer type
short Short integer type
short means short int, covering at least -32767..32767, commonly 16 bits. It combines with unsigned; promotions make %d or %u suitable for printing.
| Category | Type specifiers |
|---|---|
| Kind | Keyword / Statement |
| C standard | C89 / C90 |
📝 Syntax
short s = -100;
▶ Example
Edit the C code below and click Run; the server compiles and executes it:
Output:
sum = 750
🏷️ Related type specifiers
📚 Related Tutorials
❓ FAQ
QIs short 16 bits on every platform?
ANo. The standard specifies a minimum representable range, not a fixed physical width, although 16 bits is common on desktops. For an exact width, consider the fixed-width types in stdint.h instead of assuming short's width.
QShould printf use %d or %hd for short?
AA short argument undergoes default argument promotion and is passed as int, so %d prints its promoted value. %hd is also a standard conversion; do not confuse it with scanf, where %hd expects a pointer to short.
QIs the sum of two short values still a short?
AThe operands usually undergo integer promotion to int, and the addition produces int, not short. Assigning the result back to short converts it; an out-of-range result is implementation-defined or may raise a signal.