Assume that z has been initialized to 50. The values from 0 to 50 should be totaled.
While (z>=0)
sum = sum + z
Module Module1
Sub Main()
Dim z As Integer = 50
Dim sum As Integer = 0
While (z >= 0)
sum = sum + z
z -= 1
End While
Console.WriteLine("Sum = " + sum.ToString())
Console.ReadLine()
End Sub
End Module
Comments
Leave a comment