The most popular choice of secret papers before th

2022-07-24
  • Detail

Secret examination paper before the examination in 2005 - select 21

to constitute excessive current (21). The output result of the following program is

main()

{int a=-l, b=l, K;

if ((+a 0) &! (b-- =0))

printf ("%d%dn", a, b);

else

printf ("%d%dn", B, a);

a) -l l b) 01

c) 10 d) 0

(21) c

knowledge points: judgment of if conditions

evaluation: the priority of logical operators is as follows:! (non) → (and) →|| (or), but the concept of short circuit should be paid special attention to in this problem: as long as one of the expressions on both sides of an operator is false, the value of the entire sum operation expression is false. When the system executes, it first operates the expression on the left. If it is false, the system will not judge the expression on the right of the operator, and directly uses the short circuit principle to get the value of the entire sum operation expression as 0. Since ++a is used after operation, b-- is used before operation. Therefore, after executing ++a, the value of a is 0, which does not meet the conditions. Therefore, a makes the slight unevenness of the sample surface have little impact on the hardness value as L. according to the short-circuit principle, B is still 0. Then execute else statement and output L 0

(22) among the following options, s can be defined as a legal structural variable

A) typedef struct abc

{ double a;

char b[10];

}s;

B ) struct

{ double a;

char b[10];

}s;

C) struct ABC

{ double a;

char b[10];

}

ABC s;

d) typedef abc

{double a;

char b[10];

}

abc s:

(22) b

knowledge points: definition of structural variables

evaluation: three methods can be used to define variables of a structural type:

① define the structural type first, and then define the variable name

② define variables while defining types

③ directly define the structure type variable, that is, the structure name does not appear

option B complies with the third definition method

(23) please read the program:

include

include

main()

{

char*sl= "ABCDEF", *s2= "ab";

s1++; s2+;

printf ("%dn", StrCmp (S1, S2));

}

output results of the above program yes uu

a) positive number b) negative number C) zero d) uncertain value

(23) a

knowledge points: application of string comparison function StrCmp ()

evaluation: StrCmp (x1, x2) is a string comparison function. When X1 and X2, the return value is a positive number. When "SL" and "S2" in X1 represent the address of the first character in the two strings respectively, s1++ and s2++ point the pointer to the second character of the string, then *sl is "bcdef', *s2 is" B ". In string comparison. The size is determined by the size of the ASCII code value of the character at the corresponding position of each string. The ASCII code value of "B" is 66, and the ASCII code value of "B" is 98, so SL S2, the return value is a positive number

(24) please read the program:

include

func (int a, int b) {

int c:

c=a+b:

return c:

}

main() {

int x=6, y=7, z=8, R;

r=func func ((x--, y++, x+y), z--);

printf ("%d \ n", R);

}

the output result of the above program is uu

a) 11 b) 20 C) 2L d) 31

(24) c

knowledge points: self increasing and self decreasing operations

evaluation: the function func() returns the sum of two formal parameters. The first formal parameter is the sum of X and y after self decreasing and self increasing respectively. Where (x--, y++, x+y) is a comma expression, and its value should be equal to x+y, so the value of the entire expression (x--, y++, x+y) is 13, The value of the second formal parameter is 8 (it should be used first and then increased automatically according to the syntax rules), so the return value of fun() is 13+8=21

(25) please read the program:

include

main()

{

int a, B;

for (a=1, b=l; a =100; a++) {

if (B =20) and civil field break;

if (b%3==1) {b+=3; continue;}

b_= 5:

}

printf("%d\n",a);

}

the output result of the above program is uuu

a) 7 b) 8 c) 9 d) 10

(25) b

knowledge points: break statements and continue statements

comments: break statements are used to jump out of the loop body and continue to execute the statements below the loop body; The continue statement is used to jump out of this loop, that is, to skip the statements in the loop body that have not been executed, and then determine whether to execute the loop next time. "%" is a remainder operator. When the first loop is executed, the condition (b%3==1) is true, b=4, and the next loop continues. This is repeated. When b=22, the condition (B =20) is false, and the loop jumps out. At this time, the loop is cycled 8 times, that is, a=8

(26) please read the program fragment (there is no space character in the string):

printf ("%dn", strlen ("ATS \ n0l2 \ l\")

the output of the above program fragment is \

a) L1 b) 10 C) 9 d) 8

(26) c

knowledge points: length of string

evaluation: the purpose of this statement is to output the length of "ATS \ n012 \ 1 \" the string "\" represents a "\". In order to distinguish it from the escape character in printf() function, two backslashes are used in syntax instead of one backslash, so it it is only one character, and "\ L" stands for the number L, It also takes up one character, "n" is the carriage return line feed character, so it takes up one character in the injection phase, plus a, t, s, 0, 1, 2, a total of 9 characters

(27) please select a set of identifiers that can be used as C language user identifiers

A)Void B)a3_ b3 C)For D)2a

define _ 123 _ ABC do

word if case sizeof

(27) b

knowledge points: C language identifier

evaluation: C language stipulates that an identifier can only be composed of letters, numbers and underscores, and the first character must be letters or underscores

Both void and define in

option a have the same name as the keyword in C language, which is illegal

the case in option C has the same name as the keyword in C language, which is illegal

2A in

option D begins with a number, and the keyword names of sizeof and c languages are the same, which is illegal

(28) please select the output results of the following programs uu

#include

sub(int*s

Copyright © 2011 JIN SHI