hello!
Plug in the value of p:-
16+2q=40
Subtract 16 from both sides:-
2q=40-16
2q=24
Divide both sides by 2:-
q=12 ✓
note:-
Hope everything is clear; if you need any clarification/explanation, kindly let me know, and I'll comment and/or edit my answer :)