Expressions, Operators & Types

Answer & solution
Official answer: 3.0
Our answer: 3
1. strlen("abc")=3 and strlen("defgh")=5. The stipulated return type is unsigned int, so subtraction is unsigned rather than signed.
2. Let the unsigned modulus be U=UINT_MAX+1. Then 3−5 wraps to U−2, a large positive value, not signed −2. The comparison is against unsigned c=0 and is therefore true.
3. The conditional selects strlen(s)=3. Conversion of 3 to int is representable and printf prints 3. The surprising result comes from unsigned subtraction; the printed void main is a separate source portability issue.
void main is a nonstandard hosted-C entry point; the exam assumes an implementation accepting it.