Operators & Expressions MCQs

18 MCQs  — Fundamental Programming MCQs  (Page 1 of 2)

Practice Operators & Expressions MCQs with correct answers and explanations. These questions are from the Fundamental Programming MCQs section.

In C++, what happens with int i = 0; if (i != 0 && 10 / i > 1) {...}?
The condition is true
The condition is false and no division occurs
Compilation error
A divide-by-zero crash occurs
In C++, what is -7 / 2?
-3
Implementation-defined between -3 and -4, with no standard rule
-3.5
-4
In C, what does if (x = 0) { puts("zero"); } do?
It assigns 0 to x and the body never executes
It always prints 'zero'
Compilation error
It prints 'zero' if x was 0