#EXCE0002. 变量习题

变量习题

一、单选题(每题 10 分,共 50 分)

1.在计算机程序中,什么是变量?(     \ \ \ \ \

{{ select(1) }}

  • 一种数据类型
  • 一组代码
  • 一种程序结构
  • 一个用于存储值的容器

2.如果用两个 intint 类型的变量 aabb 分别表达长方形的长和宽,则下列哪个表达式不能用来计算长方形的周长?(     \ \ \ \ \

{{ select(2) }}

  • a+b2a + b * 2
  • 2a+2b2 * a + 2 * b
  • a+b+a+ba + b + a + b
  • b+a2+bb + a * 2 + b

3.下列哪个不是正确的变量名?(     ~ ~ ~ ~ ~

{{ select(3) }}

  • x123
  • aa
  • 123x
  • _aa

4.下列哪种数据类型用于存储整数?(     ~ ~ ~ ~ ~

{{ select(4) }}

  • float
  • double
  • int
  • char

5.如果输入数据为 9999100100 ,下列代码的输出结果为?(     ~ ~ ~ ~ ~

#include <iostream>
using namespace std;
int main () {
    int a, b;
    cin >> a >> b;
    a = a + b;
    b = a - b;
    a = a - b;
    cout << a << " " << b << endl;
    return 0;
}

{{ select(5) }}

  • 99 100
  • 99 99
  • 100 100
  • 100 99

二、判断题(每题 10 分,共 50 分)

6.变量命名可以包括数字,字母,下划线;且数字不能开头。(     ~ ~ ~ ~ ~

{{ select(6) }}

  • 正确
  • 错误

7.intint 类型的变量能够表示的数据大小是有限的,范围在 -2147483648 ~ 2147483647 之间。 (     ~ ~ ~ ~ ~

{{ select(7) }}

  • 正确
  • 错误

8.下面代码执行输入 1 2 ,输出结果为 3 。(     ~ ~ ~ ~ ~

#include <iostream>
using namespace std;
int main () {
    int a, b;
    cin >> a >> b;
    cout << a + b;
    return 0;
}

{{ select(8) }}

  • 正确
  • 错误

9.下面代码的输出结果为 5 。(     ~ ~ ~ ~ ~

#include <iostream>
using namespace std;
int main () {
    int a;
    5 = a;
    cout << a;
    return 0;
}

{{ select(9) }}

  • 正确
  • 错误

10.下面代码的输出结果为。 (     ~ ~ ~ ~ ~

1
8
5

#include <iostream>
using namespace std;
int main () {
    int a = 581;
    cout << a % 10 << endl;
    cout << a / 10 % 10 << endl;
    cout << a / 100 % 10 << endl;
    return 0;
}

{{ select(10) }}

  • 正确
  • 错误