How to resolve the algorithm Logical operations step by step in the FutureBasic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Logical operations step by step in the FutureBasic programming language
Table of Contents
Problem Statement
Write a function that takes two logical (boolean) values, and outputs the result of "and" and "or" on both arguments as well as "not" on the first arguments. If the programming language doesn't provide a separate type for logical values, use the type most commonly used for that purpose. If the language supports additional logical operations on booleans such as XOR, list them as well.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Logical operations step by step in the FutureBasic programming language
Source code in the futurebasic programming language
window 1, @"Logical Operations", (0,0,480,270)
Boolean a, b
text ,,,,, 43
print @"In FB, the Boolean constants _true or YES = 1, _false or NO = 0"
print fn StringByPaddingToLength( @"", 39, @"-", 0 )
print @"a\tb\tand\tor\txor\tnand\tnor"
print fn StringByPaddingToLength( @"", 39, @"-", 0 )
a = NO : b = NO : print a, b, a and b, a or b, a xor b, a nand b, a nor b
a = NO : b = YES : print a, b, a and b, a or b, a xor b, a nand b, a nor b
a = YES : b = NO : print a, b, a and b, a or b, a xor b, a nand b, a nor b
a = YES : b = YES : print a, b, a and b, a or b, a xor b, a nand b, a nor b
print
print "FB also has shorthand operator expressions"
print fn StringByPaddingToLength( @"", 39, @"-", 0 )
print @"a\tb\t&&\t||\t^^\t^&\t^|"
print fn StringByPaddingToLength( @"", 39, @"-", 0 )
a = NO : b = NO : print a, b, a && b, a || b, a ^^ b, a ^& b, a ^| b
a = NO : b = YES : print a, b, a && b, a || b, a ^^ b, a ^& b, a ^| b
a = YES : b = NO : print a, b, a && b, a || b, a ^^ b, a ^& b, a ^| b
a = YES : b = YES : print a, b, a && b, a || b, a ^^ b, a ^& b, a ^| b
HandleEvents
You may also check:How to resolve the algorithm Matrix transposition step by step in the Groovy programming language
You may also check:How to resolve the algorithm Isograms and heterograms step by step in the Ruby programming language
You may also check:How to resolve the algorithm Call a function step by step in the Phixmonti programming language
You may also check:How to resolve the algorithm JSON step by step in the Halon programming language
You may also check:How to resolve the algorithm Periodic table step by step in the V (Vlang) programming language