#CIEXP263C2T. C++T2卷63

C++T2卷63

C++T2卷63

一、单选题(共10题)

1.以下代码的输出是?

int y = 2;
switch (y) {
    case 1: cout << "1";
    case 2: cout << "2";
    case 3: cout << "3"; break;
    default: cout << "4";
}

{{ select(1) }}

  • 2
  • 23
  • 234
  • 4

2.以下代码的输出是?

int a = 7;
int b = 3;
if (a % b == 0)
    cout << "Divisible";
else
    cout << "Not divisible";

{{ select(2) }}

  • Divisible
  • Not divisible
  • 编译错误
  • 无输出

3.以下代码的输出是?

int a = 10;
int b = 5;
int c = 15;
if (a >= b && a >= c)
    cout << "A is largest";
else if (b >= c)
    cout << "B is largest";
else
    cout << "C is largest";

{{ select(3) }}

  • A is largest
  • B is largest
  • C is largest
  • 编译错误

4.以下代码的输出是?

for (int i = 3; i > 0; i--){ 
    cout << i << " ";
 }

{{ select(4) }}

  • 3 2 1
  • 1 2 3
  • 3 2 1 0
  • 无输出

5.以下代码的输出是?( )

int i = 10; 
 while (i > 0) 
{ 
    if (i == 5) 
       break;
    cout << i << " ";
    i--; 
}

{{ select(5) }}

  • 10 9 8 7 6
  • 10 9 8 7 6 5
  • 10 9 8 7 6 5 4
  • 无输出

6.'do-while' 循环至少执行几次?{{ select(6) }}

  • 0
  • 1
  • 2
  • 不确定

7.以下代码的输出是?

for (int i = 1; i <= 2; i++) {
    for (int j = 1; j <= 3; j++) {
        cout << i << "," << j << " ";
    }
    cout << endl;
}

{{ select(7) }}

  • 1,1 1,2 1,3 2,1 2,2 2,3
  • 1,1 2,1 1,2 2,2 1,3 2,3
  • 1,1 1,2 2,1 2,2
  • 无输出

8.以下定义数组的方式不正确的是?{{ select(8) }}

  • int arr[] = {1, 2, 3};
  • int arr[3] = {};
  • int arr[3] = {1, 2, 3, 4};
  • int arr[3] = {1, 2};

9.以下代码的输出是?

int a[3] = {10, 20, 30};
cout << a[2-1];

{{ select(9) }}

  • 10
  • 20
  • 30
  • 地址值

10.以下代码的输出是?

int x[4] = {5, 10, 15, 20};
for (int i = 3; i >= 0; i--) 
	cout << x[i] << " "; 

{{ select(10) }}

  • 20 15 10 5
  • 5 10 15 20
  • 0 0 0 0
  • 无输出

二、判断题(共10题)

1.'if'语句必须要有'else'语句。{{ select(11) }}

  • 正确
  • 错误

2.'switch'语句的条件表达式可以是浮点型。{{ select(12) }}

  • 正确
  • 错误

3.'for'循环的初始化部分可以不定义新变量。{{ select(13) }}

  • 正确
  • 错误

4.'for'循环的步进表达式可以不赋值。{{ select(14) }}

  • 正确
  • 错误

5.当条件表达式为假时,程序会进入对应的 'while'循环。{{ select(15) }}

  • 正确
  • 错误

6.'while'循环的循环体至少执行一次。{{ select(16) }}

  • 正确
  • 错误

7.在嵌套循环中,'break'可以跳出多层循环。{{ select(17) }}

  • 正确
  • 错误

8.'do-while'循环的条件表达式外不需要圆括号。{{ select(18) }}

  • 正确
  • 错误

9.数组名可以是关键字。{{ select(19) }}

  • 正确
  • 错误

10.小写字母的ASCII码比大写字母的大。{{ select(20) }}

  • 正确
  • 错误