vb for the topic of the loop control structure

Updated on technology 2024-05-13
3 answers
  1. Anonymous users2024-02-10

    When i=1, j=1, k=1 to 3, so a=a+1 is executed 3 times, a=+1+1+1=3

    When i=2 and j=1, then k=1 to 3, a=a+1 is executed 3 more times, so a=3+3=6

    j=2 then k=2 to 3, a=a+1 is executed 2 more times, so a=6+2=8

    When i=3, j=1 then k=1 to 3, a=a+1 is executed 3 times, so a=8+3=11

    j=2 then k=2 to 3, a=a+1 is executed 2 times, so a=11+2=13

    j=3 then k=3 to 3, a=a+1 is executed 1 more time, so a=13+1=14

    The last value of a is 14, which is to examine the number of executions of a=a+1 in this problem.

  2. Anonymous users2024-02-09

    **, multiline=true for text1, scrollbar=2

    private sub command1_click()for i = 1 to 3

    for j = 1 to i

    for k = j to 3

    a = a + 1

    vbcrlf & "i=" & i & ";j=" & j & ";k=" & k & ";a=a+1=" & a

    next k

    next j

    next i

    print a

    end sub

    The result is as follows:

    i=1;j=1;k=1;a=a+1=1

    i=1;j=1;k=2;a=a+1=2

    i=1;j=1;k=3;a=a+1=3

    i=2;j=1;k=1;a=a+1=4

    i=2;j=1;k=2;a=a+1=5

    i=2;j=1;k=3;a=a+1=6

    i=2;j=2;k=2;a=a+1=7

    i=2;j=2;k=3;a=a+1=8

    i=3;j=1;k=1;a=a+1=9

    i=3;j=1;k=2;a=a+1=10

    i=3;j=1;k=3;a=a+1=11

    i=3;j=2;k=2;a=a+1=12

    i=3;j=2;k=3;a=a+1=13

    i=3;j=3;k=3;a=a+1=14

  3. Anonymous users2024-02-08

    Because the first two for loops will be x=3, it shouldn't need too much introduction, it's very good.

    The key is the last for loop, 2 cycles from 1 to 2.

    First cycle: x=3+5=8

    Second cycle: x=8+5=12

    So the final result is 13

    I hope the landlord can understand and help the landlord.

Related questions
9 answers2024-05-13

do while not

Output line. for i=1 to 3 >>>More

9 answers2024-05-13

Let's talk about the difference between foreach and for, foreach is traversal for objects, and there is no need to define the number of loops, but there is a disadvantage, foreach traversal takes read-only data, and cannot add, delete and modify objects in foreach, while for loops can. >>>More

5 answers2024-05-13

int main()

int i,j,k; >>>More

20 answers2024-05-13

Internal and external circulation is exactly what the name suggests. Internal circulation is to let the air only circulate in the car, and the air in the car is driven by the blower to circulate. The external circulation is to connect the inside of the car and the outside world, during the driving of the vehicle, the air flow will use the wind pressure to automatically inhale into the car, and when the air outside the car is stationary, it can also enter the blower along the airway, thus blowing into the car. >>>More

16 answers2024-05-13

The theoretical cycle has assumed that refrigerants are excluded. >>>More