ScripticXLearn programming visually
Platform
Problems
Community
Leaderboard
Learn
Docs
BasicsVariablesLoopsInput / Output
Examples
BasicsLoopsConditionsAlgorithms
What's newHelpContact
Loading…

Examples

MiniScript+

ExamplesMiniScript+
Fundamentals
Basic programsConditions
Programming patterns
LoopsAlgorithms
Examples/Conditions

Conditions

Practical branching examples using IF, ELSE, comparisons, and logical expressions.

On this page
Simple IFIF and ELSEEven or oddMaximum of two values

Conditions choose which instructions a program executes.

Simple IF#

MS+simple-if.mspMiniScript+
1temperature = 282​3IF temperature > 25 THEN4  PRINT "Warm"5END

IF and ELSE#

Exactly one branch runs.

MS+if-else.mspMiniScript+
1score = 722​3IF score >= 50 THEN4  PRINT "Passed"5ELSE6  PRINT "Try again"7END

Even or odd#

MOD returns the remainder after division.

MS+even-odd.mspMiniScript+
1number = 142​3IF number MOD 2 = 0 THEN4  PRINT "Even"5ELSE6  PRINT "Odd"7END

Maximum of two values#

MS+maximum.mspMiniScript+
1first = 52second = 83​4IF first > second THEN5  PRINT first6ELSE7  PRINT second8END

Test each condition with values on both sides of the boundary and with a value exactly on the boundary.

PreviousBasic programsNextLoops

On this page

Simple IFIF and ELSEEven or oddMaximum of two values