当前位置:网站首页>C language test question 3 (grammar multiple choice question - including detailed explanation of knowledge points)

C language test question 3 (grammar multiple choice question - including detailed explanation of knowledge points)

2022-06-11 04:44:00 Dream of new

Multiple choice questions

1.( A  ) It's the composition C The basic unit of a language program .
A、 function         B、 The process        C、 Subroutines     D、 Subroutines 

2.C Language programs start from      C           Start execution .
 A)  The first executable statement in the program      B)  The first function in the program 
   C)  In program main function           D)  Include the first function in the file 
   
3、 What is correct in the following statement is (  C  ).
   A、C Language programs always start with the first defined function 
   B、 stay C Language program , The function to be called must be in main( ) Function 
   C、C Language programs always start from main( ) The function starts executing 
   D、C In language programs main( ) Functions must be placed at the beginning of the program 
   
4. The following about C The language is wrong ( B )       .
A) C The working process of the program is editing 、 compile 、 Connect 、 function  
B) C The language is not case sensitive .
C) C The three basic structures of a program are sequential 、 choice 、 loop  
D) C The program from main The function starts executing 
5. The following correct identifiers are (C ).
A.-a1             B.a[i]          C.a2_i          D.int t
5~8 Questions of the same type 
 Examination site : Naming rules for identifiers 
(1)	 Only letters 、 Numbers 、 Underline makes up 
(2)	 A number cannot start an identifier 
(3)	 Keywords cannot be used as identifiers 
 Options A Medium “-” , Options B in “[” And “]” dissatisfaction (1); Options D Medium int Keyword , dissatisfaction (36. The following C What is legal in the language user identifier is ( B ).
     A)3ax   B)x   C)case   D)-e2    E)union
 Options A The identifier in starts with a number, which is not satisfied (2); Options C,E Are keywords , dissatisfaction (3); Options D Medium “-” dissatisfaction (1);

7. Of the following four sets of options , Correct C The language identifier is ( C  ).
A)  %x           B)   a+b       C)  a123          D) 123
 Options A Medium “%” , Options B in “+” dissatisfaction (1); Options D The identifier in starts with a number, which is not satisfied (28、 The following four sets of strings can be used as C The of identifiers in language programs is ( A ).
   A、print  _3d   db8  aBc     B、I\am  one_half  start$it  3pai
   C、str_1  Cpp  pow  while    D、Pxq  My->book  line#  His.age  
 Options B Medium “\”,”$” , Options D in “>”,”#”,”.”,”-” dissatisfaction (1); Options C Medium while Keyword , dissatisfaction (3
9.C Simple data types in the language include (D  ).
   A、 integer 、 Real type 、 The logical model         B、 integer 、 Real type 、 The logical model 、 Character 
   C、 integer 、 Character 、 The logical model       D、 integer 、 Real type 、 Character 
10. stay C Language program , expression 5%2 The result is   C   .
        A)2.5     B)2      C)1         D)3
 See the textbook for details P52~53.
% For the remainder operator , This operator can only operate on integer data . And the symbol is the same as the modulus .5%2=1;     5%-2=1;(-5%2=-1;(-5%-2=-1;
/ For quotient operator , This operator can be used for integer 、 character 、 Floating point and other types of data ,5/2=2
11. If int a=3,b=4; Then the conditional expression "a<b? a:b" The value of is __A__.
A) 3         B) 4            C) 0       D) 1
 See the textbook for details P97.
 expression 1? expression 2: expression 3
 So let's evaluate the expression 1,
 If the expression 1 establish ,   Then select the calculation expression 2, And the expression 2 As the value of the entire large expression ;
 If the expression 1 Don't set up , Then select the calculation expression 3, And put the expression 3 As the value of the entire large expression 
 In this question a<b The expression is equivalent to 1,a The expression is equivalent to 2,b The expression is equivalent to 3.
a by 3,b by 4.a<b expression 1 establish , So the expression is evaluated 2, And put the expression 2 The value of is a The value in , And as the value of the entire expression , So the value of the whole expression is 3
12. if int x=2,y=3,z=4  Expression x<z?y:z The result is ( B  ).
     A)4   B)3    C)2    D)0  E)1
13.C In language , The values of relational expressions and logical expressions are ( B   )    .
	A) 0         B) 0 or 1        C) 1       D) ‘T’ or ’F’
14.  below (  D   ) The value of the expression is 4.
     A)  11/3            B)  11.0/3
     C)  (float)11/3    D)  (int)(11.0/3+0.5)
14~16 Entitled the same type 
 See the textbook for details P54~56.1) Perform mathematical operations on elements of the same data type (+-*/) The result still keeps the original data type .
(2) Perform mathematical operations on elements of different data types , First, unify the data types , The unified standard is to convert low-precision types to high-precision data types .
 Options A,11 And 3 Two integers ,11/3 The data type of the result should also be an integer , So it will 3.666666 Round off all the decimal parts of , Keep only integers , therefore 11/3=3.
 Options B,11.0 It's a real number ,3 Integers , Therefore, we should first unify the data types , Convert integer data 3 Convert to 3.0, After conversion, the data types are unified into real data , Options B Turn into 11.0/3.0, The data type of the result should also be real data , So options B 11.0 /3=3.666666
 Options C, Integer first 11 Cast , Convert to real 11.0, So options C Turn into 11.0/3, Then the calculation process 、 Results and options B Same as 
 Options D, First calculate 11.0/3, Its calculation process 、 Results and options B Same as , obtain 3.666666; Calculate again 3.666666+0.5=4.166666, The final will be 4.166666 Cast type to integer , That is, to round off all the decimal parts , The result is 4

15. Set integer variable  a=2, Then execute the following statement , Floating point variables b The value of the 0.5 Yes. (  B )
A.b=1.0/a           B.b=(float)(1/a) 
  C.b=1/(float)a      D.b=1/(a*1.0)
16.  if “int n; float f=13.8;, execute “n=(int)f%3” after ,n The value of is (A)
A.1               B.4                 C.4.333333         D.4.6(int)f“ It means that you will f The value in is cast to an integer , the 13.8 Round off the decimal part of , Convert to 13; And then calculate 13%3, The result is 1, Then assign the result to the variable n, therefore n The value of is 1
17.  The following pair of one-dimensional arrays a The correct explanation is :   D    
A)	char a(10); 			B) int a[]; 
C)int k=5,a[k];      D)char  a[3]={
    ‘a’,’b’,’c’};
 See the textbook for details P143~144, The definition of one-dimensional array 、 initialization 
 Type character   Array name  [ Constant expression ]
 The type character refers to the type of array element in the array ; The array name should conform to the identifier naming rules ; The constant expression is the length of the exponential group ( The number of elements in the array ), Its value can only be an integer , It can't be a variable , And from 1 Start counting .
 Options A, Constant expressions can only be placed in brackets  [ ] in 
 Options B, Only when initializing an array ( The assignment ) The length of the array can be omitted only when ,B It's not true in China a To initialize .
 Options C, A constant expression cannot be a variable .
18. The following can be applied to one-dimensional arrays a The initialization statement is : (    C    )
  A. int a[5]=(0,1,2,3,4,)  B. int a(5)={
    }  
C. int a[3]={
    0,1,2}       D. int a{
    5}={
    10*1}
 See the textbook for details P145, The definition of one-dimensional array 、 initialization 
 Options B,D, Constant expressions can only be placed in brackets  [ ] in 
 Options A, An array can be seen as an ordered collection of several elements of the same data type , So initialize it as a set , Use {
     } Initialize it , Options A It was used ().

19. stay C The correct definition of one-dimensional integer array in language is    D    .
        A)int a(10);          B)int n=10,a[n]; 
C)int  n;a[n];        D)#define N 10
                       int a[N]; 
20、 It is known that :int  a[10];  On the other hand a The correct reference to an array element is (  D  ).
   A、a[10]     B、a[3.5]     C、a(5)     D、a[0]
 See the textbook for details P144, References to array elements 
 Array name [ Subscript ]
 When referencing array elements ,[ ] The subscript in is the logical address subscript , It can only be an integer , It can be a variable , And from 0 Start counting 
int  a[10] Represents the definition of a containing 10 Array of integer data a, The logical address subscript range of the array element is 0~9, namely a[0]  Represents the... In the group 1 Elements ; a[1]  Represents the... In the group 2 Elements ; a[2]  Represents the... In the group 3 Elements ; ......;a[9]  Represents the... In the group 10 Elements .
 Options A, More than array a Logical address subscript range ;
 Options B, Logical address subscripts can only be integers 
 Options C, Logical address subscripts can only be placed in [ ] in 

21. If there is the following array description , be i=10;a[a[i]] The element value is (C ).
int a[12]={
    1,4,7,10,2,5,8,11,3,6,9,12};
A.10          B.9           C.6           D.5
 First calculate a[a[i]] The inner layer of the a[i], because i=10, therefore a[i] namely a[10]. 
a[10] The corresponding elements in the following array are 9.  therefore a[a[i]] That is to say a[9]
a[9] The corresponding elements in the following array are 6.  therefore a[9] That is to say 6


22. If so stated :int a[][3]={
    {
    1,2,3},{
    4,5},{
    6,7}};  The array a The size of the first dimension of is : ( B  )
  A.  2     B.  3     C.  4   D. No definite value 
 One dimensional size of two-dimensional array , That is, the number of rows of a two-dimensional array , In the subject , Assign a value to a two-dimensional array by row , So there are a few curly braces inside , The array has just a few lines 

23. The correct definition of a two-dimensional array is ( C )
 See the textbook for details P149~152, Definition of 2D array 、 initialization 
 Type character   Array name  [ Constant expression ][ Constant expression ]
 A two-dimensional array can be seen as a matrix 
 The type character refers to the type of array element in the array ; The array name should conform to the identifier naming rules ; The first constant expression is the number of rows of the exponential group ; The second constant expression is the number of columns in the exponential group ; The value of a constant expression can only be an integer , It can't be a variable , And from 1 Start counting .
 When initializing a one-dimensional array, the array length can be omitted 
 When initializing a two-dimensional array, the number of rows can be omitted , But the number of columns cannot be omitted 
 Options A,B, The number of columns is omitted 
 Options D, Does not conform to the general form of two-dimensional array definition , That's ok 、 Column constant expressions should be placed in different places [] in 

A.int a[ ] [ ]={
    1,2,3,4,5,6};     B.int a[2] [ ]={
    1,2,3,4,5,6};
C.int a[ ] [3]={
    1,2,3,4,5,6};     D.int a[2,3]={
    1,2,3,4,5,6};

24. It is known that int a[3][4]; The correct reference to the array element is __C___
       A)a[2][4]    B)a[1,3]   C)a[2][0]    D)a(2)(1) 
 See the textbook for details P150, References to array elements 
 Array name [ Subscript ] [ Subscript ]
 When referencing array elements ,[ ] The subscript in is the logical address subscript , It can only be an integer , It can be a variable , And from 0 Start counting 
 first [ Subscript ] Indicates the line logical address subscript , the second [ Subscript ] Indicates the logical address subscript of the column .
 See... For the illustration of this problem P149 chart 6.7
 therefore a Logical address range of the row 0~2;a Logical address range of the column 0~3;
 Options A, Column logical address subscript is out of range 
 Options B,D, The reference form of is incorrect .

25.C The type of function return value in language is determined by     A      Decisive .
    A) The type specified when the function is defined           B) return Expression type in statement  
    C)  The data type of the argument when the function is called  D)  Data type of formal parameter 
    
26.  stay C In language , The data type of the function refers to ( A )
A  The data type of the value returned by the function            B.  Data type of function parameter 
C  The data type of the argument when the function is called    D. Any specified data type 

27.   On function call , The following statement is correct ( B )
 A. The return value must be brought back after the function call 
 B. Actual parameters and formal parameters can have the same name 
 C. Global variables cannot be used for data transfer between functions 
 D. The calling function and the called function are always in the same file 
 
28.  stay C In language , The keyword representing the static storage category is : (   C   )
A) auto   	B) register   	C) static    	D) extern

29. Variable with no storage category specified , The implied storage category is ( A  ).
        A)auto   B)static   C)extern   D)register 
30.  If there are the following statements :
       struct  student
        {
     int num;
          char name[ ];
          float score;
         }stu;
      The following statement is incorrect : ( D )
A. struct It's a keyword for struct type  
B. struct student  Is a user-defined structure type 
C. num, score Are all structure member names         
D. stu Is the user-defined structure type name 

31. If there are the following statements :
       struct  date
        {
     int year;
          int month;
          int day;
         }brithday;
      The following statement is incorrect __C___.
A) struct Is the keyword used when declaring the structure type        
B) struct date  Is the user-defined structure type name 
C) brithday Is the user-defined structure type name    
D) year,day  Are all structure member names 
32.  The following pairs of structural variables stul Member of the age The illegal reference to is    B     
struct student
{
     int age;
int num;
}stu1,*p;
p=&stu1;
A) stu1.age   B) student.age   C) p->age    D) (*p).age
33. It has the following definitions :
struck sk
{
       int a;
float b;
}data;
int *p;
 If you want to make P Point to data Medium a Domain , The correct assignment statement is   C    
A) p=&a;		B) p=data.a;	C) p=&data.a;	D)*p=data.a;
34. The following description statement is provided :
          typedef  struct  stu
          {
      int  a;
             float  b;
          } stutype;
    What is wrong in the following description is ( D  ).
   A、struct Is the keyword of structure type    
B、struct stu Is a user-defined structure type   
   C、a and b Are all structure member names 
D、stutype Is the user-defined structure variable name 
35.  sentence int *p; Illustrates the    C   .
A)p Is a pointer to a one-dimensional array     
B)p Is a pointer to a function , This function returns a int Type data 
C)p It's pointing int Pointer to type data    //  Definition of pointer P223
D)p Is the function name , This function returns a pointer to int Pointer to type data 
36. The following incorrect definition is ( A  ).
A.	int *p=&i,i;                  B.int *p,i;
C.int i,*p=&i;                  D.int i,*p;
 Options A First define an integer pointer variable p, And then the variables i Address assigned to p. However, no variables have been defined at this time i Therefore, the compiler cannot obtain variables i The address of .(A And C contrast , Options C Define variables first i, Is... In memory i Allocate space , therefore i The address in the memory space can be determined ; Then define p, It can be p Fu i The address of ,C correct )
37.  If so stated :int n=2,*p=&n,*q=p, Then the following illegal assignment statement is : ( D  )
A)p=q        B)*p=*q     C)n=*q      D)p=n
p,q Both are integer pointer variables , Both can only store the address of integer variables .
 Options A,q In is the address , Therefore, this address can be assigned to p
 Options B,*p Express p The object pointed to n The content of , It's an integer ;*q Express q The content of the object pointed to , Because of the definition of q Initialize it when , take p in n The address to q, therefore p In the store n The address of ,*q Express q The object pointed to n The content of . therefore *p=*q  amount to  n=n;
 Options C,n=*q   Equivalent to n=n;
 Options D,p Only addresses can be stored in the , Can't be n Assign an integer value in to p
38. There are sentences :int a[10],; be   B    Is for pointer variables p Correct definition and initialization of .
A)int p=*a;  B)int *p=a;   C)int p=&a;  D)int *p=&a;
 Options A,a It's an array name , Not pointer variable name , So not available * Label array name a
 Options C,a It's an array name , The array name is the address , No more address symbols . And in defining pointer variables p when , The variable name should be preceded by *, mark p It's a pointer variable 
 Options D,a It's an array name , The array name is the address , No more address symbols .
39. If there is a description statement “int a[5],*p=a;, The correct reference to the array element is ( C ).
A.a[p]            B.p[a]              C.*(p+2)         D.p+2
 First define an integer array a,a The length of is 5, Then define a pointer variable p, And at the same time p To initialize , Will array a Address assigned to p. So now p Array stored in a The first address , That is, the first element in the array a[0] The address of .
 A reference to the subscript of an array element ( See p144),  General form   Array name [ Subscript ]  Where the subscript is the logical address subscript , from 0 Start counting , Subscripts in square brackets can be variables , It could be an expression , But the result must be an integer .
 Options A,p The address is stored in , Is not an integer , Can't do subscript of array element 
 Options B,a It's an array name , The array name is the address , Is not an integer , Can't do subscript of array element 
 Options C,( a key !!! See p231~234)   p+2 Indicates the address of the next two elements in the same array , At present p Point to a[0], be p+2 Express a[2] The address of , therefore *(p+2) Express a[2] The content of 
40.  There are the following procedures 
int  a[10]={
    1,2,3,4,5,6,7,8,9,10},*P=a;
 Then the value is 9 The expression of   B    
A) *P+9            B) *(P+8)          C) *P+=9         D) P+8
( a key !!! See p231~234)
 First define an integer array a,a The length of is 5, Then define a pointer variable P, And at the same time P To initialize , Will array a Address assigned to P. So now P Array stored in a The first address , That is, the first element in the array a[0] The address of .
 Array 9 The corresponding is a[8],  Options B,P+8 Represents the last... In the array 8 Addresses of elements , namely a[8] The address of .*(P+8) Indicates the content stored in the address , namely a[8] Value .
    Options A,*P Express P The content of the object pointed to , here P Point to a[0], *P namely a[0] Value 1. *P+9=1+9=10
 Options C,*P Express P The content of the object pointed to , here P Point to a[0], *P namely a[0] Value . therefore *P+=9  namely *P =*P+9,  Equivalent to a[0]=a[0]+9.
 Options D,P+8 Represents the last... In the array 8 Addresses of elements , namely a[8] The address of , Instead of a[8] The value in .
41.  stay C In language , With    D    As a string end flag 
A)’\n’      B)’ ’      C)0’    D)’\042. The following data belong to “ String constant ” Yes. ( A ).
A.“a”         B.{
    ABC}         C.‘abc\0’         D.‘a’
 Several characters make up a string 
 stay C In language , Use single quotation marks to identify characters ; Use double quotation marks to identify the string 
 Options B,C, Use them separately {
    } and ’’ Identification string 
 Options D, Identification characters .
43. It is known that char x[]="hello", y[]={
    'h','e','a','b','e'};,  Then the correct description of the length of two arrays is    B   .
A) identical      B)x Greater than y    C)x Less than y   D) None of the above answers is true 
C In language , An end flag bit is required after the string '\0', Usually, the system will automatically add .
 The initialization of one-dimensional array can be in the form of string ( For example, this question array x), It can also be in the form of a character set ( For example, this question array y). When initialized as a string , Array x You don't have to store characters in a string , Also store the end flag bit after the string , So the array x The length of is 6; When initializing as a character set , Array y, Only the elements in the collection are stored , So the array y The length is 5

原网站

版权声明
本文为[Dream of new]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110440508847.html