"Fossies" - the Fresh Open Source Software Archive

Member "FreeBASIC-1.09.0-win64/examples/manual/operator/andalso.bas" (1 Jan 2022, 723 Bytes) of package /windows/misc/FreeBASIC-1.09.0-win64.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Visual Basic source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 '' examples/manual/operator/andalso.bas
    2 ''
    3 '' NOTICE: This file is part of the FreeBASIC Compiler package and can't
    4 ''         be included in other distributions without authorization.
    5 ''
    6 '' See Also: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOpAndAlso
    7 '' --------
    8 
    9 '' Using the ANDALSO operator to guard against array access
   10 '' when the index is out of range
   11 
   12 Dim As Integer isprime(1 To 10) = { _
   13     _ ' 1  2  3  4  5  6  7  8  9  10
   14         0, 1, 1, 0, 1, 0, 1, 0, 0, 0 _
   15     }
   16 
   17 Dim As Integer n
   18 Input "Enter a number between 1 and 10: ", n
   19 
   20 '' isprime() array will only be accessed if n is in range
   21 If (n >= 1 And n <= 10) AndAlso isprime(n) Then
   22     Print "n is prime"
   23 Else
   24     Print "n is not prime, or out of range"
   25 End If