Book of tasks on programming. Old version

 

 by Aliaksandr N. Prykhodzka

 

list, college, of, clipboard, window, breakpoint, begin, частота, параметр, по убыванию, bit, courses, компиляция, jsp, floppy, метод, then, xsl, library, полиморфизм
 

for valuable work you must have JavaScript (allow active content)

Visual Basic. B.7. Nest of tasks. Operator If with different operators

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.7.1     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    dd = 0
    For i = 1 To 15
        If i Mod 4 = 1 Then
            dd = dd + 1
        End If
    Next i
    AA = dd
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.7.2     Answer      Pascal-analogue

Determine a value produced by function AA .


Function AA() As Integer
    dd = 0
    k = 0
    Do
        k = k + 1
        If (k \ 3) > 3 Then
            dd = dd + 1
        End If
    Loop Until (k = 15)
    AA = dd
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.7.3     Answer      Pascal-analogue

Determine a value produced by function AA .


Function AA() As Integer
    dd = 0
    k = 15
    Do
        k = k - 1
        If k \ 3 > 3 Then
            dd = dd + 1
        End If
    Loop Until k = 1
    AA = dd
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.7.4     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    dd = 0
    k = 0
    While k < 15
        k = k + 1
        If k Mod 2 = 1 Then
            dd = dd + 1
        End If
    Wend
    AA = dd
End Function


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

B.7.5     Answer      Pascal-analogue      Java-analogue

Determine a value produced by function AA .


Function AA() As Integer
    dd = 0
    k = 16
    While k > 1
        k = k - 1
        If k Mod 2 = 1 Then
            dd = dd + 1
        End If
    Wend
    AA = dd
End Function


 

©   Aliaksandr Prykhodzka    1993 - 2007