Bird
0
0
CNC Programmingscripting~20 mins

G-code program structure in CNC Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
G-code Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this G-code program snippet?
Consider this G-code snippet for a CNC milling machine:
N10 G21
N20 G90
N30 G00 X10 Y10
N40 G01 X20 Y20 F100

What is the position of the tool after line N40 executes?
CNC Programming
N10 G21
N20 G90
N30 G00 X10 Y10
N40 G01 X20 Y20 F100
AThe tool is at absolute position X20 Y20
BThe tool is at relative position X30 Y30
CThe tool is at relative position X20 Y20
DThe tool is at absolute position X10 Y10
Attempts:
2 left
💡 Hint
G90 sets absolute positioning, G00 and G01 move the tool to specified coordinates.
🧠 Conceptual
intermediate
1:30remaining
Which line defines the program start in a typical G-code file?
In a standard G-code program, which line usually marks the start of the main machining commands?
AThe line with M30
BThe line with T1
CThe line with G28
DThe line with G00 or G01 after setup commands
Attempts:
2 left
💡 Hint
Look for the first movement command after setup.
🔧 Debug
advanced
2:00remaining
Identify the error in this G-code snippet
This G-code snippet is intended to move the tool to X50 Y50 and then start cutting:
N10 G90
N20 G01 X50 Y50 F200
N30 G00 X0 Y0
N40 M30

What is the problem with this program?
CNC Programming
N10 G90
N20 G01 X50 Y50 F200
N30 G00 X0 Y0
N40 M30
AThe program lacks a spindle start command (M03 or M04)
BThe feed rate F200 is missing a unit
CG90 should be after M30
DG00 cannot be used after G01
Attempts:
2 left
💡 Hint
Check if the spindle is turned on before cutting moves.
🚀 Application
advanced
1:30remaining
How many lines are in this G-code program excluding comments?
Count the number of executable lines in this G-code program (ignore lines starting with ';' which are comments):
; Program start
N5 G21
N10 G90
; Move to start
N15 G00 X0 Y0
N20 G01 X10 Y10 F150
N25 M05
N30 M30
CNC Programming
; Program start
N5 G21
N10 G90
; Move to start
N15 G00 X0 Y0
N20 G01 X10 Y10 F150
N25 M05
N30 M30
A7
B6
C8
D5
Attempts:
2 left
💡 Hint
Count only lines that do not start with ';'.
🧠 Conceptual
expert
1:00remaining
What is the effect of the M30 command in a G-code program?
In a CNC program, what does the M30 command do when executed?
AStarts the coolant flow
BPauses the program and waits for operator input
CStops the spindle and ends the program, rewinding to start
DMoves the tool to the home position
Attempts:
2 left
💡 Hint
Think about program end and reset commands.