Skip to content
doubtly

1 answer

Answer: It depends on the size of int. With a 16-bit int (e.g. Turbo C), no: its range is −32768 to 32767. With a 32-bit int (GCC, Visual C++ and other modern compilers), yes.

A signed integer of n bits can store values from \(-2^{n-1}\) to \(2^{n-1} - 1\).

  • 16-bit int: \(-2^{15}\) to \(2^{15} - 1\), i.e. −32768 to 32767. 32768 is one more than the maximum, so it overflows (it typically shows up as −32768).
  • 32-bit int: −2147483648 to 2147483647, so 32768 fits easily.

The C standard only guarantees that int can hold at least −32767 to 32767. To store 32768 safely on any compiler, use long int (at least 32 bits) or unsigned int (at least 0 to 65535):

long x = 32768L;
printf("%ld", x);

You can check your compiler's limit with INT_MAX from <limits.h>.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.