Challenge - 5 Problems
Conditional Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediateOutput of a simple IF-THEN block
What will be the output of this CNC program snippet if the variable #100 is set to 5?
CNC Programming
IF [#100 GT 3] THEN #101 = 1 ENDIF M30
Attempts:
2 left
💡 Hint
Check if the condition #100 GT 3 is true when #100 is 5.
✗ Incorrect
Since #100 is 5, which is greater than 3, the condition is true, so #101 is set to 1.
💻 Command Output
intermediateBehavior of nested IF-THEN statements
Given #200 = 10 and #201 = 5, what is the value of #202 after running this code?
CNC Programming
IF [#200 GT 5] THEN IF [#201 LT 10] THEN #202 = 100 ENDIF ENDIF M30
Attempts:
2 left
💡 Hint
Both conditions must be true for #202 to be set.
✗ Incorrect
Since #200 is 10 (greater than 5) and #201 is 5 (less than 10), both conditions are true, so #202 is set to 100.
📝 Syntax
advancedIdentify the syntax error in IF-THEN usage
Which option contains a syntax error in the IF-THEN statement?
Attempts:
2 left
💡 Hint
Check if the THEN keyword is present after the condition.
✗ Incorrect
Option A is missing the THEN keyword after the condition, causing a syntax error.
🚀 Application
advancedUsing IF-THEN to control spindle speed
You want to set spindle speed to 1000 if the tool number (#1) is 5, otherwise set it to 500. Which code snippet achieves this?
Attempts:
2 left
💡 Hint
Check the correct placement of ELSE and ENDIF keywords.
✗ Incorrect
Option C correctly uses THEN, ELSE, and ENDIF to set spindle speed conditionally.
🧠 Conceptual
expertUnderstanding IF-THEN evaluation order
Consider this code snippet:
IF [#10 GT 0] THEN
IF [#20 LT 5] THEN
#30 = 1
ELSE
#30 = 2
ENDIF
ELSE
#30 = 3
ENDIF
If #10 = 0 and #20 = 3, what is the value of #30 after execution?
Attempts:
2 left
💡 Hint
The outer IF condition controls whether the inner IF runs.
✗ Incorrect
Since #10 is 0 (not greater than 0), the outer IF condition is false, so the ELSE block sets #30 to 3.
