Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Several c++ basic exercises need detailed analysis, thank you.
Several c++ basic exercises need detailed analysis, thank you.
D,C,B,B,B,D

The first question: A+= A-= A * A; = =》a+=(a-=(a * a)); The result is: -264 (compilation and execution results are consistent).

Question 2: s = s+1/n; Since n is an int type and 1/n is a modular operation, as long as n is greater than 1, 1/n is always zero.

Question 3: As long as the variable is defined, if the variable is not initialized, the compiler will assign an uncertain value to the variable at compile time. The length of the unvalued bit is the same as the type of the variable, so the expression of addition is correct.

Question 4: It is enough to specify the operation rules of (a, c).

Question 5: If (b = = 0) m =1; n = 2; C/c++ language stipulates that the ending character of a statement is a semicolon ";" And "}", this sentence has two semicolons, so it is two sentences.

Question 6: This question needs to know the difference between variable assignment and pointer assignment. A=b= 10 and *p=a= 10 are different, *p=a= 10, and the value of the p pointer memory is actually the address of the variable a in the memory, and the first one is a=b=65438+.

a = b,b = c,c = a; The result of sequential execution is:

a=b,// (a=30,b=30,c = 40);

b = c,//(a=30,b=40,c = 40);

c = a; //(a=30,b=40,c = 30); (Consistent execution results after compilation)