当前位置:网站首页>2. operator and expression multiple choice questions

2. operator and expression multiple choice questions

2022-06-25 14:57:00 --988

1、 according to C User identifier naming rules specified by language , What cannot appear in the identifier is (B).

A. Capital

B. Connector

C. Numeric character

D. Underline

2、 What is wrong in the following statement is (A).

A. User defined identifiers allow the use of keywords

B. The user-defined identifier should try to “ Know what you know ”

C. User defined identifiers must start with letters or underscores

D. User defined identifiers , Big 、 Lower case letters represent different symbols

remarks :① The user identifier consists of letters 、 Underline 、 Numbers are made up of these three aspects , But it must start with a letter or an underscore ;

② System reserved keywords cannot be used ;

③ Case sensitive , Can be used as a variable name .

3、C The operator in the language that an object must be an integer number is (A).

A.%

B.\

C.% and \

D./

The object of the remainder operation is an integer number

4、 The following can correctly define the shaping variables a、b and c Give them initial values 5 The sentence is (D).

A.int a=b=c=5; ( Initialization cannot use this form of continuous assignment )

B.int a,b,c=5; ( Only to c assignment 5)

C.a=5,b=5,c=5;( To illustrate a,b,c The type of )

D.int a=5,b=5,c=5;

5、 Execute the following two statements “int c=1,c2=2,c3;c3=1.0/c2*c1;” after , Variable c3 The value of is (A).

A.0

B.0.5

C.1

D.2

The result of the expression on the right is 0.5, But because of the assigned variable c3 Is an integer , Therefore, the integer part is assigned to c3, namely c3 As the result of the 0.

6、C The simplest data types in the language include (B).

A. integer 、 implement 、 The logical model

B. integer 、 Real type 、 Character

C. integer 、 Character 、 The logical model

D. integer 、 Real type 、 The logical model 、 Character

7、 In the following options , The value is 1 The expression of ().

A.1-'0'

B.1-'\0'

C.'1'-0

'\0'-'0'

The difference in value between a number and its corresponding character 48, namely ‘0’ Of ASCII by 48,‘1’ by 49, In turn , and ‘\0’ Is an empty character ,ASCII by 0, So only B The result of the option is 1

8、 The following variable definitions are set “int k=7,x=12”, Can make the value 3 The expression of (D).

A.x%=(k%=5)

B.x%=(k-k%5)

C.x%=k-k%5

D.(x%=k)-(k%=5)

9、 set up x and y Are all int Type variable , Then the statement “x+=y;y=x-y;x-=y” The function is (D).

A. hold x and y Arrange from large to small

B. hold x and y Arrange from small to large

C. No definite result

D. In exchange for x and y The value in

10、 Integer variables x and y The values of are equal and non 0 value , Then... In the following options , The result is 0 The expression of (D).

A.x||y

B.x|y

C.x&y

D.x^y

^ For XOR operation , Otherwise 1, Same as 0

& For and operation , If both values are true 1, If there is a false value, it is false

11、 The following about unary operators ++、-- What's right in my account is (C).

A. Their operands can be any variable or constant

B. Their operands can be char Type variables and int Type variable , But it can't be float Type variable

C. Their operands can be int Type variable , But it can't be double Type variables and float Type variable

D. Their operands can be char Type variable 、int Type variables and float Type variable

12、 Set variables x by float Type and assigned , Then... Can be used in the following statements x Keep the value in to two decimal places , And the third digit is rounded off (C).

A.x=x*100+0.5/100.0;

B.x=(x*100+0.5)/100.0;

C.x=(int)(x*100+0.5)/100.0;

D.x=(x/100+0.5)*100.0;

13、 If there are the following definitions “char a;int b;float c;double d;”, Expression a*b+d-c The type of value is (D).

A.float

B.int

C.char

D.double

Arithmetic conversion : When two operand types are different , At least one of these types needs to be converted to the other , Sometimes both may have to be converted into int type , Otherwise, the operation will not . The following is based on the priority of the transformation :

long double

double

float

unsighed long int

long int

unsighed int

int

14、 Of the following options , Illegal character constants are (C).

A.'t'

B.'n'

C."n"

D.'\t'

Characters are mainly divided into single characters enclosed in single quotation marks and escape characters , Note the escape characters

原网站

版权声明
本文为[--988]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200516003297.html