ADVERTISEMENT
ADVERTISEMENT

VB.Net program to check the given number is POSITIVE or NEGATIVE using conditional operator

Here, we are going to learn how to check the given number is POSITIVE or NEGATIVE using conditional operator in VB.Net?
Submitted by Nidhi, on November 26, 2020

Here, we will read an integer number and check the given number is POSITIVE or NEGATIVE, and then print the appropriate message on the console screen.

Program/Source Code:

The source code to check the given number is POSITIVE or NEGATIVE is given below. The given program is compiled and executed successfully.

'VB.Net program to check the given number is 
'POSITIVE or NEGATIVE.

Module Module1
 
    Sub Main()

        Dim num As Integer = 0
        Dim result As String

        Console.Write("Enter number: ")
        num = Integer.Parse(Console.ReadLine())

        result = If((num < 0), "Number is NEGATIVE", "Number is POSITIVE")
        Console.WriteLine(result)

        Console.ReadLine()
    End Sub

End Module

Output:

Enter number: -3
Number is NEGATIVE

Explanation:

In the above program, we created a module Module1 that contains the Main() method. In the Main() method we created a local variable num and result. After that, we read the value of num.

result = If((num < 0), "Number is NEGATIVE", "Number is POSITIVE")

In the above code, we checked the given number is POSITIVE or NEGATIVE, after that print the appropriate message on the console screen.

VB.Net Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


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.