I. multiple choice questions
1. The number of real parameters in the following function call statements is (D ).
Excc (vl, v2), (v3, v4, v5), v6 );
(A) 3 (B) 4 (C) 5 (D) 6
2. In the C/C ++ Program, (). (A) function definitions can be nested, but function calls cannot be nested.
(B) function definitions cannot be nested, but function calls can be nested.
(C) Neither function definition nor function call can be nested.
(D) function definitions and function calls can be nested.
3. If a defined function has a return value, the following statements about the function call are incorrect: (D ).
(A) function calls can be used as independent statements. (B) function calls can be used as real parameters of A function.
(C) function calls can appear in expressions (D) function calls can be used as the form parameters of a function.
4. If the following call statement exists, the header of the incorrect fun0 function is (B ). Void main ()
{...
Int a [50], n;
...
Fun (n, & a [9]);
...
}
(A) void fun (int m, int x []) (B) void fun (int s, int h [41])
(C) void fun (int p, int * s) (D) void fun (int n, int)
5. The functions of the following functions are (C ).
Fun (char * p2, char * pl)
{
While (* p2 = * pl )! = '')
{P1 ++; p2 ++ ;}
}
(A) copy the string referred to by pl to the memory space indicated by p2
(B) assign the address of the string referred to by pl to the pointer p2
(C) Compare the strings indicated by pointers of pl and p2.
(D) check whether there are any strings indicated by the pointers pl and p2.
Ii. Read the running results of the program analysis program
6. The output result of the following program is (B ).
Float fun (int x, int y)
{Return (x + y );}
Int main ()
{
Int a = 2, B = 5, c = 8;
Printf ("% 3.0f", fun (int) fun (a + c, B), a-c ));
}
(A) Compilation error (B) 9 (C) 21 (D) 9.0
7. In the following program, the sort function sorts the data in array a in ascending order. After the program runs, the output result is (C ).
Void sort (int a [], int n)
{
Int I, j, t;
For (I = 0; I <n-1; I ++)
For (j = I + 1; j <n; j ++)
If (a [I] <a [j])
{T = a [I]; a [I] = a [j]; a [j] = t ;}
}
Int main ()
{
Int a [10] = {1, 2, 4, 5, 6, 7, 8, 9, 10}, I;
Sort (& a [3], 5 );
For (I = 0; I <10; I ++)
Printf ("% d,", a [I]);
Printf ("");
}
(A), (B), (C), (D) 8, 7, 6, 5, 4, 3, 2, 1, 9, 10
4. Read the program to answer questions
8. The output result of the following section is (4321 ).
Int si (int * s1, int y)
{
Static int i1 = 3;
Y = s1 [i1];
I1 --;
Return (y );
}
Int main ()
{
Int s [] = {1, 2, 4}, I, x = 0;
For (I = 0; I <4; I ++)
{
X = si (s, x );
Printf ("% d", x );
}
Printf ("");
}
9. The execution result of the following programs is (5 10 17 32 15 38 ).
Void fun (int * s, int n1, int n2)
{
Int I = n1, j = n2;
While (I <j)
{
* (S + I) + = * (s + j); * (s + j) + = * (s + I );
I ++; j --;
}
}
Int main ()
{
Int a [6] = {1, 2, 4, 5, 6}, I, * p =;
Fun (p, 0, 3 );
Fun (p, 1, 4 );
Fun (p, 3, 5 );
For (I = 0; I <6; I ++)
Printf ("% d", * (a + I ));
Printf ("");
}
10. It is known that the isaplha (ch) function is used to determine whether the independent variable ch is a letter. If so, the function returns a value of 1; otherwise, 0. The output of the following program is (Itis ).
# Include <ctype. h>
Void fun4 (char str [])
{
Int I, j;
For (I = 0, j = 0; str [I]; I ++)
If (isalpha (str [I]) str [j ++] = str [I];
Str [j] =;
}
Int main ()
{
Char ss [80] = "lt is! ";
Fun4 (ss );
Printf ("% s", ss );
}
11. The output result of the following program is (12 ).
Unsigned fun6 (unsigned num)
{
Unsigned k = 1;
Do {
K * = num % 10;
Num/= 10;
} While (num );
Return (k );
}
Int main ()
{
Unsigned n = 26;
Printf ("% d", fun6 (n ));
}
12. The output result of the following program is (9 ).
Long fun5 (int n)
{
Long s;
If (n = 1) | (n = 2 ))
S = 2;
Else
S = n + fun5 (n-1 );
Return (s );
}
Int main ()
{
Long x;
X = fun5 (4 );
Printf ("% ld", x );
}
13. The following program completes the function (sort one-dimensional arrays in ascending order ).
# Define SIZE 5
Void func (int data [SIZE]);
Int main ()
{
Int I, buf [SIZE];
Printf ("please input % d numbers:", SIZE );
For (I = 0; I <SIZE; I ++)
Scanf ("% d", & buf [I]);
Func (buf );
For (I = 0; I <SIZE; I ++)
Printf ("% 5d", buf [I]);
}
Void func (int data [SIZE])
{
&