char char int? Why?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In C and similar languages, char + char usually produces an int, not a char. That surprises people because both operands started as characters, but arithmetic on small integer types follows the language's integer-promotion rules.
The short answer is: char values are promoted before arithmetic happens. By the time the addition runs, the operands are already being treated as int.
Characters Are Small Integers
A char stores a small integer value. It may represent a character code such as 'A', but inside the expression it is still a numeric type.
For example:
'A' has a numeric code, so adding 1 gives the next code point. The important part is that the result expression is computed as int.
Why Promotion Happens
C applies the integer promotions to types smaller than int before most arithmetic operations. That includes char and short.
This design avoids doing arithmetic in tiny types that may be awkward for the machine and helps standardize expression behavior across platforms.
So conceptually:
- '
charbecomesint' - the other
charbecomesint - addition happens as
int + int
That is why the expression type is typically int.
What This Means in Practice
If you write:
the printf argument is the integer sum of the promoted values, not a two-character string and not a char.
If you want the result back in a char, you must convert explicitly:
That cast tells the compiler you are intentionally narrowing the arithmetic result back to a smaller type.
Watch Out for Overflow and Sign
Promotion does not remove every pitfall. A char may be signed or unsigned depending on the implementation, and converting an int result back to char can lose information.
So while promotion makes arithmetic more regular, narrowing back to char still deserves care.
This Is Not About ASCII Alone
People often explain this with ASCII examples, but ASCII is not the reason the promotion happens. The promotion rule is about C's arithmetic semantics, not about any particular character encoding.
ASCII examples are just convenient because letter codes are easy to visualize.
Assignment Is a Different Step
One reason this feels confusing is that expression type and assignment target are separate ideas. The addition is performed as int, but you can still assign the result to a char variable afterward. That assignment is a narrowing conversion step, and it may truncate or wrap depending on the value and implementation details.
Common Pitfalls
- Thinking
char + charshould staycharbecause both operands started as characters. - Forgetting that
printfwith%dis showing the integer value after promotion. - Casting back to
charwithout considering overflow or sign issues. - Assuming ASCII is the cause instead of the language's integer-promotion rules.
- Treating character literals as if they were fundamentally different from small integers in expressions.
Summary
- In C,
charis a small integer type. - Before arithmetic,
charoperands are usually promoted toint. - That is why
char + charyields anintexpression. - Casting back to
charis a separate, narrowing conversion. - The key concept is integer promotion, not ASCII itself.

