Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

计算机程序设计第三四章

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

设a、b和c都是int型变量,且a=3,b=0,c=5,则以下值为0的表达式是___

a)

 'a'&&'b'

b)

a&&b||c

c)

 a&&b&&c

d)

a||b&&c

2.

在嵌套使用if语句时,C语言规定else总是___

a)

 和之前与其具有相同缩进位置的if配对

b)

和之前与其最近的if配对

c)

和之前与其最近不带else的if配对

d)

和之前的第一个if配对

3.

以下程序运行后的输出结果是___

main()

{ 

int a=0,b=0;

a=10;

b=20;

printf("a+b=%d\n",a+b);

}

a)

a+b=10

b)

a+b=30

c)

30 

d)

出错

4.

以下程序运行后的输出结果是___。

main()

{ 

double d=3.2; 

int x,y;

x=1.2;

y=(x+3.8)/5.0;

printf("%d\n",d*y);

}

a)

3

b)

3.2

c)

0

d)

3.07

5.

以下程序运行后的输出结果是___。

main()

{  unsigned short a=65536;  int b;

printf("%d\n",b=a);

}

a)

65536

b)

0

c)

1

d)

-1

6.

若要求在if后一对圆括号中表示a不等于0的关系,则能正确表示这一关系的表达式为___。

a)

a<>0

b)

!a

c)

a=0

d)

a

7.

下列叙述中正确的是___。

a)

break语句只能用于switch语句

b)

在switch语句中必须使用default

c)

break语句必须与switch语句中的case配对使用

d)

在switch语句中不一定使用break语句

8.

以下程序运行后的输出结果是___。

main()

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

if(a=1) b=1;c=2;

else    d=3;

printf("%d,%d,%d,%d\n",a,b,c,d);

}

a)

0,1,2,0

b)

0,0,0,3

c)

1,1,2,0

d)

编译有错

9.

若有定义:float x=1.5;  int a=1,b=3,c=2;  则正确的switch语句是___。

a)

switch(x)                      

{  case 1.0:printf("*\n");

case 2.0:printf("**\n");  }

b)

switch((int)x);

 {  case 1:printf("*\n");

  case 2:printf("**\n");  }

c)

switch(a+b)

{  case 1:printf("*\n");   

case 2+1:printf("**\n");  } 

d)

switch(a+b)

    {  case 1:printf("*\n");

case c:printf("**\n");  }

10.

下面的程序段的输出结果是___。

int x=3;

if((x%2)?printf("**%d",x):printf("##%d\n",x));

(a)