执行Dim X,Y AS Integer 语句后则X,Y的默认值均为0
错
举一反三
- 下列代码执行后,窗体上显示( )。 Dim x As Integer, y As Integer x = 50: y = 30 If x > y Then x = x - y Else y = y x If x < y Then x = x 20 Form1.Print x, y
- 执行下列语句后,变量X的值是: Dim X As Integer X = 0 X = 13 / 3
- Sub s1(ByVal x As Integer, ByVal y As Integer) Dim t As Integer t = x: x = y: y = t End Sub Sub s2(x As Integer, y As Integer) Dim t As Integer t = x: x = y: y = t End Sub 则以下说法中正确的是( )。
- 设x、y、t均为int型变量,则执行语句:x=y=3;t=++x||++y;后,y的值为
- 执行下列程序段后,变量y的值为( )。 Dim x As Integer,y As Integer x = 7 y = 3 If x >= 10 Then y = x - y ElseIf x>= 7 Then y = x + y Else y = x End If A: 21 B: 10 C: 4 D: 3
内容
- 0
在VB中,使用变量前一般应对变量进行定义。以下变量定义语句错误的是()。 A: Dim x As Integer B: Dim x As Integer,y As Single C: Var x,y:Integer D: Dim x As Integer,y As Integer
- 1
下面可以正确定义2个整形变量和一个字符型变量的语句是() A: Dim x%, y As Integer, n As String B: Dim x As Integer, y, n As String C: Dim x, y As Integer, n As String D: Dim x%, y$, n As String
- 2
设x,y,z均为整型变量,现有如下语句x=y=z=1;(x||(y&&++z));,则执行这个语句后y的值为 A: 2 B: 1 C: 0 D: 不定值
- 3
若已有定义:int x=5, y; 则执行语句:y = x>10 ? x / 10 : x>0 ? x : -x ; 后,y的值是( )。
- 4
中国大学MOOC: 下面的程序执行完后a,b的值分别为______。 Dim x, y, a, b As Integer x = 12 : y = 8 a = 1 : b = x * y Do While x Mod 2 = 0 And y Mod 2 = 0 x = x 2 y = y 2 a = a * 2 Loop Do While x <> y If x > y Then x = x - y Else y = y - x End If Loop a = a * x b = b a