The document discusses IF statements and their structure. IF statements allow code to execute conditionally based on whether a test is true or false. Examples are provided of IF statements in pseudocode and Visual Basic code that check conditions like age and temperature and produce different outputs depending on the result.
2. IF is All Around Us Everyday
IF it is cold out THEN you will put a coat on
ELSE leave the coat at home
IF you do your homestudy THEN no detention
ELSE you get a detention
3. IF Is Like A Test With An Effect
The test: Is it cold? The Effect if the test is True:
Put your coat on
IF it is cold out THEN you will put a coat on
ELSE leave the coat at home
The Effect if the test is
False: Leave coat at home
4. The Structure of IF in VB
If <TEST> Then
<CODE IF THE TEST IS TRUE>
Else :
<CODE IF THE TEST IS FALSE>
End If
5. Are You Old Enough To Drink?
Module Module1
Sub Main()
Dim age As Integer = 14
If age > 16 Then
Console.WriteLine("old enough")
Console.ReadLine()
Else : Console.WriteLine("Your not old enough!!")
Console.ReadLine()
End If
End Sub
End Module
6. Are You Old Enough To Drink? With
User Input
Module Module1
Sub Main()
Dim age As Integer
Console.WriteLine("ENTER YOUR AGE")
age = Console.ReadLine()
If age > 16 Then
Console.WriteLine("old enough")
Console.ReadLine()
Else : Console.WriteLine("Your not old enough!!")
Console.ReadLine()
End If
End Sub
End Module