C语言 百分网手机站

C语言考试试题(3)

时间:2020-10-03 10:27:56 C语言 我要投稿

C语言考试试题

  三、阅读题(每格2分,共20分)

  1.

  Private Sub Form_Click()

  Dim x As Integer

  Static y As Integer

  x = x + 3

  y = y + 4

  Form1.Print "x="; x, "y="; y

  End Sub写出程序运行时连续单击三次窗体后,Form1上的输出结果。

  X=3,y=4 , x=3,y=8 , x=3,y=12 注:全局变量执行一次内存就消失了,static整个程序结束则消失

  2.

  Private Sub Form_Click()

  Dim i As Integer, k As Integer, c As Integer

  For i = 1 To 5

  If i Mod 2 = 0 Then

  k = k + 2

  Else

  c = c + 3

  End If

  Next i

  Print k, c

  End Sub

  写出程序运行时单击窗体后,Form1上的输出结果。

  K=4 , c=9

  3.

  Private Sub Command1_Click()

  Dim A(1 To 5) As Integer

  Dim b As Integer

  For b = 1 To 5

  A(b) = b

  Next b

  Text1.Text = A(b - 2)

  End Sub

  写出程序运行时单击Command1按纽后,Text1上的输出结果。

  4

  4.

  Sub Change(ByVal x As Integer, ByVal y As Integer)

  Dim t As Integer

  t = x

  x = y

  y = t

  Print x, y

  End Sub

  Private Sub Form_Click()

  Dim a As Integer, b As Integer

  a = 5: b = 8

  Change a, b

  Print a, b

  End Sub

  写出程序运行时单击Command1按纽后,Form1上的输出结果。

  8 5 , 5 8

  5.

  Private Sub Form_Click()

  Static Sum As Integer

  For i = 1 To 3

  Sum = Sum + i

  Next i

  Print Sum

  End Sub

  写出程序运行时点击窗体两次后,变量Sum的值。

  6 , 12

  6.

  Sub test(i As Integer)

  i = i + 3

  End Sub

  Private Sub Form_Click()

  Dim x As Integer

  x = 8

  Print "x="; x

  Call test(x)

  Print "x="; x

  End Sub

  写出程序运行时,单击窗体后显示的值。

  7.

  Private Sub Form_Click()

  Dim I As Integer, j As Integer

  Dim c As Integer

  c = 0

  For I = 1 To 3

  For j = 1 To 3

  c = c + 4

  Next j

  Next I

  Print c

  End Sub

  写出程序运行时,单击窗体后显示的值。

  36