C language programming formative assignment 3, C language programming formative assignment 3–4.doc

C programming formative assignments 3–4

C language programming formative homework 3

multiple choice

1. There is a syntax error in the following (C) function declaration statement.

A.AA(int a,int b); B.AA(int ,int) C.AA(int a;int b) D.AA(int a,int)

2. (C) below cannot be used as the return type of a function.

A.void B.int C.new D.long

3. The correct function prototype statement below is (B).

A.int Function(void a); B.void Function(int);C.int Function(a); D.void int(double a);

4. The number of actual parameters contained in the function call func(exp1, exp2), exp3*exp4-exp5) is (B).

A.1 B.2 C.4 D.5

5. In the identifiers below, (C) is the file-level scope.

A. function parameters b. Statement label C. External static class identifier D. automatic class identifier

6. In the following identifiers, (B) has global scope.

A. function parameters b. global variable c. Internal static class identifier D. automatic variable

7. Assuming that p is a pointer to float data, the address of the data pointed to by p+1 is (C) bytes larger than the address of the data pointed to by p.

A.1 B.2 C.4 D.8

8. Assuming that a is a character array name, the address of a[8] is (B) bytes larger than the first address of the array.

A.4 B.8 C.16 D.32

9. Assuming a is an array name, (B) below indicates an error.

A.a[i] B.*a++ C.*a D.*(a+1)

10. The correct statement to use the calloc function to create a one-dimensional array with 10 integer elements is (C).

A.int *p=calloc(10,2); B.int *p=callo(10;

C.int *p=calloc(10,4); D.int *p=malloc(10);

11. Assuming that the variable m is defined as "int m=7;", the correct statement to define p is (B).

A.int p=&m; B.int *p=&m; C.int &p=*m; D.int *p=m;

12.假定k是一个double类型的变量,则定义指向k的变量p的正确语句为(D)。

A.double p=&k; B.double *p=&k; C.double &p=*k; D.char *p=”Thank you!”;

13.假定一条定义语句为“int a[10],x,*pa=a;”,若要把数组a中下标为3的元素赋值给x,则不正确的语句为(D)。

A.x=pa[3]; B.x=*(a+3); C.a=a[3]; D.x=*pa+3;

14.假定有定义“int b[10];int *pb;”,则不正确的赋值语句为(D)。

A.pb=b; B.pb=&b[0]; C.pb=b+2; D.pb=b[5];

15.假定指针变量p定义为“int *p=new int(100);”,要释放p所指向的动态内存,应使用语句(A)。

A.delete[p]; B.delete *p; C.delete &p; D.delete []p;

16.假定指针变量p定义为“int *p=calloc(30,sizeof(int));”,要释放p所指向的动态内存,应使用语句(D)。

A.delete[p]; B.deldete(p); C.free[]p; D.free(p);

二、填空题

1.在C语言中,一个函数由函数头和_函数体_组成。

2.在函数外定义的变量称为全局变量,若没有被初始化则系统隐含对它所赋的初值为_0_。

3.如果一个函数只允许同一程序文件中的函数调用,则应在访函数定义前加上的C保留字为_static_。

4.如果一个函数直接或间接地调用自身,这样的调用被称为_递归_调用。

5.调用系统函数时,要先使用#include命令包含该函数的原型语句所在_头_文件。

6.函数形参的作用域是该函数的_函数体_。

7.假定p所指对象的值为25,p+1所指对象的值为46,则*p++的值为_25_。

8.假定p所指对象的值为25,p+1所指对象的值为46,则*++p的值为_46_。

9.假定p所指对象的值为25,p+1所指对象的值为46,则执行“*(p++);”语句后,p所指对象的值为_46_。

10.假定a是一个指针数组,则a+1所指对象的地址比a地址大_4*i _字节。

11.若要把一个整型指针p转换为字符

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324223431&siteId=291194637
Recommended