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.

CategoryType specifiers
KindKeyword / Statement
C standardC89 / C90

📝 Syntax

short s = -100;

▶ Example

Edit the C code below and click Run; the server compiles and executes it:

Output:

sum = 750

📚 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.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏