Additional answers to C language exercises

Selected C language multiple choice questions

*1 A

The execution of a C program is from ___.

 A) The main function of this program starts and ends with the main function √

 B)The first function of this program file starts, and the last function of this program file ends

 C) The main function of this program starts and ends with the last function of this program file

 D) The first function of this program file starts and ends with the main function of this program

*2 D    

The following statement is incorrect.

A) A C source program can be composed of one or more functions

B)A C source program must contain a main function

C) The basic unit of C program is function

D) In ​​a C program, the comment can only be located after a statement

*3  B

A C language program is composed of

A) A main program and several subprograms B) Function composition

C) Composition of several processes D) Composition of several subroutines

*4 A

In the C language (take a 16-bit PC as an example), the order of the storage space length of the five basic data types is

A)char<int<1ong  int<=float<double

B)char=int<1ong  int<=float<double       char(1)int(2)long(4)float(4)double(8)

C)char<int<1ong  int=float=double

D)char=int=1ong  int<=float<double

*5  C 

If x, i, j and k are all int variables, the value of x after executing the following expression

 x=(i=4,j=16,k=32)

 A)4      B)16      C)32     D)52

*6  B

Assuming that all variables are of integer type, the value of the expression (a=2, b=5, b++, a+b) is:

 A)7    B)8   C)6   D)2

*7   C

The identifier in C language can only consist of three characters: letters, numbers and underscores, and the first character

 A) Must be a letter B) Must be an underscore

 C) must be a letter or underscore     D) can be any of letters, numbers and underscore

*8 D   

Among the following four options, the options are incorrect octal or hexadecimal numbers.

 A)  016      B)oabc       C)010      D)  0a12

      0x8f         017                  -0x11             7ff

      018         0x8                  0x16            -123

Octal begin with 0, hexadecimal with 0x, 0X beginning

*9  C 

If there is algebraic expression 3ae/bc, the incorrect C language expression is:

 A) a/b/c*e*3      B)3*a*e/b/c

 C)3*a*e/b*c       D)a*e/c/b*3

*10 A

The types of known variables are described as follows:

   int   k,a,b;

   unsigned  long  w= 5;

  double    x=1.42;

Then the following expressions that do not conform to the C language syntax are:

A) x%(一3) B) w+=-2

C) k=(a=2,b=3,a ten b) D) a ten = a one =(b=4)*(a=3)

*11 A

The types of known variables are described as follows:

 int i=8,k,a,b;

unsigned  long  w=5;

 double  x=1.42,y=5.2;

Then the following expressions conforming to the C language syntax are:

A) a ten = a one = (b = 4) * (a = 3) B) a = a * 3 = 2

C)  x%(一3)                       D)y=f1oat(i)

*12  D  

The following incorrect statement is

A) In C programs, the comma operator has the lowest priority

B) In the C program, APH and aph are two different variables

C) If a and b are of the same type, the value in b will be placed in a after the assignment expression a=b is executed, and the value in b remains unchanged.

D) When inputting data from the keyboard, only integer values ​​can be input for integer variables, and only real values ​​can be input for real variables.

*13  B

The following assignment expression that conforms to the C language syntax is

A)d=9+e+f=d+9            B)  d=9+e,f=d+9

C) d=9 ten e, e++, d ten 9 D) d=9 ten e++=d ten 7

*30 A

Knowing that the ASCII code of the letter A is 65 in decimal, and c2 is a character type, execute the statement c2='A'十'6'一'3'; then, the value in c2

A) D B) 68 C) Uncertain value D) C

*14  D  

In the C language, the operator that requires the operand to be of integral type is.

A) /       B) ++       c) !=      D)%

*15 B

If the following variables are all integers, and num=sum=7; then execute the expression sUM=num++, sUM++, ++num and the value of sum

 A)  7        B  8         C) 9          D) 10

*16  D  

In C language, the number of bytes occupied by int har and short types of data in memory

A) Defined by the user B) Both are 2 bytes

C) is arbitrary D) is determined by the machine word length of the machine used

*17 A

If there is a description statement: cha c='\72' then the variable c

A) Contains 1 character B) Contains 2 characters

C) Contains 3 characters D) Description is illegal, the value of c is uncertain

*18 A

If defined: int a=7; float x=2.5, y=4.7; the value of the expression x+a%3*(int)(x+y)%2/4 is

A)2·500000       B)2.7500OO       C)  3.500000       D)  0.000000。

*19  C 

Suppose variable a is an integer type, f is a real type, and i is a double-precision type, then the data type of the expression 10+'a'+i*f value is

 A) int B) float C) double D) not sure

*20 A

Among the following four options, the options that are all illegal constants are.

A)'as'         B)'\\'       c)-0xl8      D)0xabc

  -0fff          '\01'        01177        '\0'

  '\0xa'         12,456       0xf"a"

*21  B

In C language, when calling a function, the following statement is incorrect .

A. Actual parameters and formal parameters each occupy an independent storage unit

B. Actual parameters and formal parameters can share storage units

Formal parameters are copies of actual parameters, that is, copies, which cannot share storage units and do not occupy the same space

C. The calling function passes the value of the actual parameter to the formal parameter

D. Formal parameters will only be allocated storage units when a function call occurs

*22  B

Assuming that the variable n is of type f1oat and m is of type int, the following can realize that the value in n retains two decimal places, and the third expression for rounding up is one by one.

A) n=(n*100+0.5)/100.0     B)m=n*100+0.5 ,n= m/100.0

C) n=n*100+0.5/100.0      D)n=(n/100+0.5)*100.0

*23  C

The data type of the expression 18/4*sqrt(4.0)/8 value is:

A) int B) float C) double D) uncertain

*24   C

Assuming that in C language, an int type data occupies 2 bytes in the memory, the value range of unsigned int type data is:

A)  0~255     B) 0~32767     C) 0~65535     D)  0~2147483647

*25    D

There is a description: char w; int x; f1oat y; double z; then the data type of the expression w* x+z-y value is:

A)float    B)char   C)int     D)double

*26    D

If there is the following definition, the expression that can make the value 3 is:

int  k= 7,x =12;

A) x%=(k%= 5) B) x%=(k一k%5)

C) x%=k- k%5 D) (x%=k)一(k%=5)

*27  C 

Assuming that the following variables are of type int, the expression whose value is not equal to 7 is

A) (x = y = 6, x + y, x + 1) B) (x = y = 6, x + y, y + 1)

C) (x = 6, x + 1, y = 6, x + y) D) (y = 6, y + l, x = y, x + 1)

*28  B

The format character %5s is used in the printf function, where the number 5 means that the output string occupies 5 columns. If the string length is greater than 5, the output is as in

A) Output the string from the left, with spaces on the right

B)All output from left to right according to the original character length

C) Output the string right-aligned, with spaces on the left

D) Output error message

*29  D

There are input sentences: scanf("a= %d,b= %d,c=%d",&a,&b,&c); To make the value of variable a 1, b is 3, c is 2, input from the keyboard The correct form of the data should be

A) 132 (Enter)

B)1,3,2(Enter)

C)a=1b=3c=2(Enter)

D)a=1,b=3,c=2 (Enter)

*30 A

The following statement that can correctly define the integer variables a, b and c and assign the initial value of 5 is

 A)int a=b= c= 5;       B) int a,b, c= 5;

 C)a= 5,b=5,c=5;     D)  a= b= c=5;

*31 A

Knowing that ch is a character variable, the following incorrect assignment statement is

A)ch='a+b';  B)ch='\0';  C)ch='7'+'9';  D)  ch=5+9;

*32  B

Knowing that ch is a character variable, the following correct assignment statement is 

A)  ch= '123';  B)  ch= '\xff';  C)  ch= '\08';  D)  ch="\";

*33  B

If there are the following definitions, the correct assignment statement is:

 int  a,b;float  x;

  A)  a=1,b=2,    B)b++;  C)  a= b= 5     D)  b= int(x);

*34  B

Assuming that x and y are variables of type f1oat, the following illegal assignment statement is

A)++x;     B)y=(x%2)/10;    C)  x*=y+8;    D)x=y=0;

*35 A

x, y, and z are all int variables, then execute the statement x=(y=(z=10)+5)-5; after that, the value of x, y and the sum is:

  A)  x=10          B) x=10       C) x=10       D)x=10

      y = 15 y = 10 y = 10 y = 5

      z=10 z=10        z=15          z=10

 *36  D      

The data types of the operands on both sides of the logical operator are one by one.

  A) can only be 0 or 1

  B) can only be 0 or non-zero positive numbers

  C) It can only be integer or character data

  D) can be any type of data

*37   C

The following descriptions of operator precedence are correct one by one.

A) Relational operator <Arithmetic operator <Assignment operator <Logical AND operator

B) Logical operator <Relational operator <Arithmetic operator <Assignment operator

C) Assignment operator <logical AND operator <relational operator <arithmetic operator

D) Arithmetic operator <relational operator <assignment operator <logical AND operator

*38  B

The highest priority of the following operators is one by one.

  A)<   B)十   C)&&     D)!=

*39   C

The correct expression to determine whether the char variable ch is a capital letter is one by one.

  A)' A' <=ch<='z'       B)(ch> = 'A')&(ch<=' z' )

  C)(ch>=' A' )&&(ch<='Z')       D)(' A' < = ch)AND('z'> = ch)

*40    D

Suppose x, y and z are int variables, and x = 3, y = 4, z = 5, then the value of 0 in the following expression is

  A)'y'&&'y'

  B)x < =y

  C) x||y+z&&y-z

  D) !(x<y)&&!z||1)

*41   C

Knowing that x = 43, ch='A', y=0, the value of the expression (x >= y && ch<'B'&&!Y) is

   A)0 B)Syntax error C)1 D)"False"  

*42   C

If you hope that when the value of A is odd, the value of the expression is "true", and the value of A is the value of an even expression

Is "false". Then the following expressions that cannot meet the requirements are:

A)  A%2= =1      B)!(A%2 = =0)       C)!(A%2)    D)  A%2

*43  B

Set int a = 1, b=2, c = 3, d = 4, m=2, n=2;

      After executing (m= a>b)&&(n=c>d), the value of n is:

    A)1      B )2       C)3      D)4

*44 A

 The value of b after executing the following statement:

    int  a=5,b=6,w=1,x=2,y=3,z=4;

    (a=w>x)&&(b=y>z);

  A)  6      B)  0      C)  1      D)  4

*45 C 

The following incorrect if statement forms are:   

  A)if(x>y && x!=y);

  B)if(x= =y)  x+=y    

  C)if(x != y)scanf("%d",&x )else scanf("%d",&y);

  D)if(X<Y) {X++;Y++;}

*46 A

The lowest precedence of the following operators is:

  A)?:       B)&&     c)+     D)  !=

*47  D  

Please read the following procedures:

    main()

    {int  a=5,b=0,c=0; 

    if(a=b+c)  printf("***\n  ");

    e1se   printf("$$$\n");

   The above procedure:

      A has a syntax error and cannot be compiled B can be compiled but not connected

      C output*** D output$$$

*48   C

The result of the following program is:

     main()    

    {int m=5;

    if(m++> 5)  printf(" %d\n",m);

    e1se     printf("%d\n",m- - );

  }

  A)4       B)5       C)6       D)7

*49  B

The output of the following program is:

      main()

      {int  x= 2,y= 一1,z=2;

if (x<y)

     if(y<0)  z= 0;

     else    z+ =1;

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

    }

    A)3      B )2       C)1      D) 0

*50  B

In order to avoid ambiguity in the nested conditional statement If-else, the C language specifies the else clause

    Always pair with ().

    A) The if indented position is the same B) The previous and nearest if

    C) The nearest if D) The if on the same line

*51  A

If the definition: int a [10], * p = a ;, the p + 5 represents: .

  A. Address of array element a[5] B. The value of array element a[5]

  C. Address of array element a[6] D. The value of array element a[6]

*52  B

If there is a conditional expression (exp)? A++:b--, the following expressions can be completely equivalent to the table

    The expression (exp) is:

    A)  (exp==0)       B)  (exp!=0)

    C)  (exp== 1)      D)  (exp!=1)   

*53  D  

In C language, the logical value "true" is.

A.true

B. Numbers greater than 0

C. Non-zero integer

D. Non-zero number

 

*54  D 

A known:

struct

{int i;char c;float a;}ex;

Then the memory space occupied by ex is        .

A.4      B. 5      C. 6     D.7

*55  B

For (expression 1;; expression 3) can be understood as       .

  A.for(expression 1; 0; expression 3)

  B.for(expression1;1;expression3)

  C.for(expression1;expression1;expression3)

  D.for(expression 1; expression 3; expression 3)

*56  C 

With program section

  int  k=10;

  while  (k=0)  k= k-1;

  Then the correct description below is

A) The while loop is executed 10 times B) The loop is an infinite loop

C) Loop body statement is not executed once D) Loop body statement is executed once

*57  B

There are the following program segments

    int  x=0,s=0;

    while  (!  x!= 0)  s+=++x;

    printf("%d",s);

    then

A) Output 0 after running the block B) Output 1 after running the block

C) The control expression in the program segment is illegal D) The program segment is executed infinitely

*58 A

The expression !E in the statement while(!E) is equivalent to:

A) E == 0 B) E! = 1 C) E! = 0 D) E == 1

*59 C

  The following defines an integer two-dimensional array a with 3 rows and 4 columns and initializes it. What is incorrect is       

  A.int a[3][4]={0};

  B.int a[][4]={ {0,1,2,3},{4,5,6,7},{8,9,10},{11,12}};

  C.int a[3][]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14};

  D.int a[3][4]={ {1,2},{1,2,3},{1,2,3,4}};

*60  C 

The running result of the following program segment is

  if    n=0;

  while(n++<=2);  printf("%d",n); 

A) 2 B) 3 C) 4 D) There is a syntax error

*61 A

In the linked list data, any data item contains one       item and one pointer item.

A) Data item B) Address item C) Parameter item         

 

*62   C

What is correct in the following description:

     A) Since the loop body statement in the do-while loop can only be an executable statement, compound statements cannot be used in the loop body

     B) The do-while loop starts with do and ends with while. You cannot write a semicolon after the while (expression)

     C) In the do-while loop body, there must be an operation that can make the expression value zero ("false") after the while

     D) In ​​the do-while loop, while can be omitted according to the situation

*63  B

If there is the following statement

 int  x=3;

 do { printf(" %d\n",x -=2);} while(!(--x));

    The above program segment

    A) The output is 1 B) The output is 1 and -2

    C) The output is 3 and 0 D) is an endless loop

*64 C

The function of the following program is to calculate the sum of the squares of the digits of the positive integer 2345. Please choose to fill in the blanks.

    #i nclude<stdio. h>

main()

       {Int n, I = 0;

n=2345

do{ sum=sum+(n%10)*n%10}; 

n=【2】;

}while(n);

printf("sum=%d",sum);} 

【2】 A)  n/1000    B)n/100      C)  n/10     D)  n%10

*65  B 

When the function is called, the actual parameter is an array name, and it is passed to the function    .

A. Array length B. The first address of the array 

C. Array elements D. The address of the last element of the array

*66   C

In C language, when referencing array elements, the data type of the array subscript is allowed to be __.

        A) Integer constant B) Integer expression

        C) Integer constant or integer expression D) Any type of expression

*67    D

The following correct description of a one-dimensional integer array a is __.

        A)  int a(10);        B)int n= 10,a[n];

        c)  int  n;           D)  #define  SIZE  10;

            scanf("%",&J1);       int a[SIZE];

            int a[n];

*68    D

If there is a description: int a[10]; then the correct reference to the a array element is __.

        A)a[10]      B) a[3.5]     C) a[5]     D) a[10-10]

*69 A

In the C language, the definition of one-dimensional array is:, the type says the specifier array name __.

A) [constant expression] B) [integer expression]    

c)[Integer Constant] or [Integer Expression] D)[Integer Constant]

*70  C

The following statement that can initialize the one-dimensional array a correctly is __.

A)  int a[10]=(0,0,0,0,0)        B)int  a[10]={}

C)  int  a[]={0};                D) int a[10]={10*1};

*71   C

The following correct description of the two-dimensional array a is __.

      A)  int a[3][];        B)  floatf a(3,4);

      C)  double a[1][4];    D)  float a(3)(4);

*72 C 

If there is a description: int a[3][4]; then the correct reference to the elements of the a array is __.

 A)  a[2][4]     B) a[1,3]     C) a[1+1][0]    D) a(2)(1);

*73  D  

If there is a description: int a[3][4]; the illegal reference to the a array element is __.

A) a[0][2*1]     B) a[1][3]      C)a[4-2][0]       D)a[0][4]

74 A  D  

In the c language, it       is a pointer operator and       an address operator.

If there is a description: int a[3][4]; the illegal reference to the a array element is __.

A)  *     B) -      C)%      D)&

75 A D   

The       function in c language is to open the file , and the humble house is to close the file.

If there is a description: int a[3][4]; the illegal reference to the a array element is __.

A)  fclose    B) fseek      C)fopen     D)frind

 

Guess you like

Origin blog.csdn.net/qq_44761243/article/details/108391911