云南大学2018至2019学年秋季学期软件学院
《高级语言程序设计》期末考试(闭卷)试A卷
满分: 100分 考试时间: 120分钟 任课教师:
专业: 序号: 学号: 姓名:
题号 | 一/30 | 二/15 | 三/35 | 四/20 | 总分/100 |
得分 | |||||
Section 1: Single Choice(2 marks for each item, total 30 marks)
1 | 2 | 3 | 4 | 5 | |||||
6 | 7 | basic语言属于高级语言8 | 9 | 10 | |||||
11 | 12 | 13 | 14 | 15 | |||||
1.In the following statements, the error is( A )
A. char str[5]="hello"; B. char str[]={'h','e','l','l','o','\0'};
C. char str[5]={"hi"}; D. char str[100]="";
2.Which following C language identifier is legal( B )
A .3ax B. x C. case D. -e2 E. union
3.If int a=3 b=4, then the conditional expression "a:b? A<b" is( A )
A 3 B 4 C 0 D 1
4.Which following descriptions of the one-dimensional array is correct ( D )
A char a(10); B int a[];
C int k=5,a[k]; D char a[3]={‘a’, ’b’, ’c’};
5.int i=10, int a[12]={1,4,7,10,2,5,8,11,3,6,9,12};The value of a[a[i]] element is ( C )
A.10 B.9 C.6 D.5
6.A variable does not specify a storage class, whose default storage class is (A )
A auto B static C extern D register
7.Which following definitions is incorrect( A )。
A. int *p=&i, i; B. int *p, i; C. int i,*p=&i; D. int i,*p;
8.The following program: int a[10]={1,2,3,4,5,6,7,8,9,10},*P=a; Which expression’s value is 9? ( B )
A *P+9 B *(P+8) C *P+=9 D P+8
9.The expression X *= Y - 2 is equivalent to the expression ( C ).
A. X= (X * Y) -2; B. X = X * Y - 2; C. X= X * (Y - 2); D. X = X ^ (Y - 2);
10.A file stream is opened by using the ( A ) function.
A. fopen() B. exit() C. fclose() D. close()
11.If int a=9,b=20;the result of the printf(″%d,%d\n″,a--,--b);is (A)
A.9,19 B.9,20 C.10,19 D.10,20
12.After the following statement is executed, the value of the n is ( C )
int n; for (n=0 ; n<100 ; n=2*n+1);
A.125 B.126 C.127 D.128
13.If g is an array of ten float, the statement ( A ) is invalid.
A. g = &grade[4]; B. *g = *(g + 3); C. *g = *g + 3; D. *g = *(&g [2]) + 3;
14.Which following string assignment statements is correct? (D)
A.string str="12345"; B. char str="12345";
C.str string="12345"; D. static char str[ ]={"12345"};
15.Given int n=2,*p=&n,*q=p; then the following assignment statement, wich is illegal ( D )
A. p=q B. *p=*q C. n=*q D. p=n
Section 2: Fill in the blanks(3 mark for each item, total 15 marks)
1.The following code fragment prints out 5
#include <stdio.h>
main()
{ int x=2,y= -1,z=5;
if(x<y)
if(y<0)
z=0;
else
z=z+1;
printf(“%d\n”,z);}
2.The following code fragment prints out 1 2 3
#include <stdio.h>
main()
{ int num=0;
while(num<=2){ num++;printf("%d ",num);}}
3.The following code fragment prints out 10 5
#include <stdio.h>
main()
{ int x, y =0;
for(x=1;x<=10;x++)
{ if(y>=10)
break;
y=y+x;
}
printf(“%d %d”,y,x);}
4.The following code fragment prints out 10
#include<stdio.h>
main()
{ int arr[ ]={30,25,20,15,10,5}, *p=arr;
p++;
printf(“%d\n”,*(p+3));}
5.The following code fragment prints out 6
#include<stdio.h>
struct cmplx
{ int x;
int y;
} cnum[2]={1, 3, 2, 7};
main( )
{
printf(“%d\n”, cnum[0].y * cnum[1].x ); }
Section 3: Please answer following questions (35 marks)
1.Please Answer the rules of programmer-created identifiers?
AN:Can be any combination of letters, digits, or underscores (_) subject to the following rules:
First character must be a letter or underscore (_). Only letters, digits, or underscores may follow the initial character. Blank spaces(空格) are not allowed. Cannot be a reserved word
2.What is "Implicit Type Conversions" and "Explicit Type Conversions" ?
AN: The automatic conversion across an assignment operator is called an implicit type conversion
The operator used to force the conversion of a value to another type is the cast operator
(dataType) expression.where dataType is the desired data type of the expression following the cast.
3.What is “Flow of control” and which are four standardized flow of control structures?
AN:Flow of control refers to the order in which a program’s statements are executed
Any algorithm can be built using combinations of four standardized flow of control structures:
Normal flow of control for all programs is sequential
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论