Thursday, July 8, 2010

Console Programs

Program 2: Use Constant Keyword Declaration

Sub main( )

     const size As integer = 5
     Dim i As integer
     For i = 1 to 5 step 1

     console.writeline(size)

     Next
     Console.readline( )
End sub

Output:
5
5
5
5
5


Program 3:

 Sub Main()
        Dim x, y, z As Integer

        Console.WriteLine("Enter the value of X:")
        x = Console.ReadLine()
        Console.WriteLine("Enter the value of Y:")
        y = Console.ReadLine()
        z = x + y
        Console.WriteLine("Sum:" & z)
        Console.ReadLine()

    End Sub

Output:
Enter the value of X:12
Enter the value of Y: 12
Sum:24

No comments: