ADVERTISEMENT
ADVERTISEMENT

VB.Net find output programs (Data Types) | Set 5

Find the output of VB.Net programs | Data Types | set 5: Practice these programs to test and enhance the knowledge of VB.Net Data Types.
Submitted by Nidhi, on June 15, 2022

Question 1:

Module VBModule
 
    Sub Main()
        dim num1 as Short = 12
        dim num2 as Short = 20
        dim num3 as Integer  = 0 
        
        num3 = len(num1)* len(num1.GetType().ToString)/len(num2) 
        
        Console.WriteLine("Result is: "&num3)
        
    End Sub
    
End Module

Output:

Result is: 12

Explanation:

In the above program, we created 3 variables num1, num2, num3 that are initialized with 12, 20, 0.

Now we evaluate the expression:

num3 = len(num1)*len(num2)/ len(num1.GetType().ToString)
num3 = 2*len("System.SByte")/2
num3 = 2*12/2
num3 = 24/2
num3 = 12

Question 2:

Module VBModule
 
    Sub Main()
        dim num1 as Int16 = 12
        dim num2 as Int16 = 20
        dim num3 as Int32  = 0 
        
        num3 = num1 * num2
        
        Console.WriteLine("Result is: "&num3)
        
    End Sub
    
End Module

Output:

Result is: 240

Explanation:

In the above program, we created 3 variables num1, num2, num3 that are initialized with 12, 20, 0.

Now we evaluate the expression:

num3 = num1 * num2
num3 = 12*20
num3 = 240

Question 3:

Module VBModule
 
    Sub Main()
        dim num1 as Float32 = 12.0
        dim num2 as Float32 = 20.0
        dim num3 as Float32  = 0.0 
        
        num3 = num1 * num2
        
        Console.WriteLine("Result is: "&num3)
        
    End Sub
    
End Module

Output:

main.vb (4,28) : error VBNC30451: 'Float32' is not declared. It may be inaccessible due to its protection level.

main.vb (5,28) : error VBNC30451: 'Float32' is not declared. It may be inaccessible due to its protection level.

main.vb (6,28) : error VBNC30451: 'Float32' is not declared. It may be inaccessible due to its protection level.

There were 3 errors and 0 warnings.

Explanation:

The above program will generate syntax errors because VB.NET does not support the type Float32.


Question 4:

Module VBModule
 
    Sub Main()
        dim num1 as System.Single = 12.0
        dim num2 as System.Double = 20.0
        dim num3 as System.Double = 0.0 
        
        num3 = num1 * num2
        
        Console.WriteLine("Result is: "&num3)
        
    End Sub
    
End Module

Output:

Result is: 240

Explanation:

In the above program, we created 3 variables num1, num2, num3 that are initialized with 12, 20, 0.

Now we evaluate the expression:

num3 = num1 * num2
num3 = 12.0*20.0
num3 = 240

Question 5:

Module VBModule
    Sub Main()
        dim str as System.String = " Hello " 
        Console.WriteLine("String is : "&len(str))
    End Sub
End Module

Output:

String is : 7

Explanation:

In the above program, we created a string str initialized with " Hello ". Then we found the length of the String using the len() method and printed the result.


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.