Home > Back-end >  O bosses explained in detail
O bosses explained in detail

Time:09-16

Set a, b, c, d, m, n are int variable, and a=5, b=6, c=7, d=8, m=2, n=2 logical expressions (m=a> B) & amp; & (n=c> D) after the operation, the n value is..., (2)
B. a. 0 1 C. 2 D.
The answer is a.

CodePudding user response:

The answer should be C

(m=a> B) & amp; & (n=c> D)
Execution order
1, a> B=0
2, m=0
Because m=0, 0 & amp; & Arbitrary number, the result is 0, the ide was optimized, n=c> D should not be executed that n keep original value,

CodePudding user response:

The logical expression (m=a> B) & amp; & (n=c> D) after the operation, do not change the original value of the variable,
The answer is C, the value is 2,

If subject to delete "logical expression", after the assignment operations, c> The value of d=0
The answer is A, the value is 0,

CodePudding user response:

The answer is C
Process:
1. (m=a & gt; B)
1.1 a & gt; B value is 0
1.2 m=0 0
2. 0 & amp; & (n=c & gt; D)
Because with any number of 0 0 (n=c & gt; D) not computation, direct return 0
So the result is n=2

CodePudding user response:

CodePudding user response:

Curious about: 0 & amp; & The NULL result is 0 or NULL?

CodePudding user response:

NULL on semantics is a NULL pointer, the equivalent of Pascal's nil, in c + + can use NULL as the integer 0, the definition of an early NULL actual is 0, then introduced in c + + 11 nullptr constants (c + + version is nil), NULL in almost all the c + + 11 compatible compiler implementation are defined as nullptr, but can still be used as the integer 0,
Strictly speaking, 0 & amp; & NULL result is false, because the type of the expression is the bool, but in c + +, false, nullptr, integer 0 can be implicit type conversion, so also can saying is 0 or nullptr or NULL (because of NULL macro definition are either 0 or nullptr),

CodePudding user response:

refer to 6th floor DelphiGuy response:
NULL on semantics is a NULL pointer, the equivalent of Pascal's nil, in c + + can use NULL as the integer 0, the definition of an early NULL actual is 0, then introduced in c + + 11 nullptr constants (c + + version is nil), NULL in almost all the c + + 11 compatible compiler implementation are defined as nullptr, but can still be used as the integer 0,
Strictly speaking, 0 & amp; & NULL result is false, because the type of the expression is the bool, but in c + +, false, nullptr, integer 0 can be implicit type conversion, so also can saying is 0 or nullptr or NULL (because of NULL macro definition are either 0 or nullptr),

Too complicated and too bother with

CodePudding user response:

C + + committee for standardization of people loved do a thing to do is put the simple things complicated, so as to show their level and originality ~ ~ ~
  • Related