Let's solve your equation step-by-step. 
(Layout equation)
5x−2+x+12=40 
Step 1: Simplify both sides of the equation. 
5x−2+x+12=40 
5x+−2+x+12=40 
(5x+x)+(−2+12)=40(Combine Like Terms) 
6x+10=40 
6x+10=40 
Step 2: Subtract 10 from both sides. 
6x+10−10=40−10 
6x=30 
Step 3: Divide both sides by 6. 
6x/6=30/6
Step 4: Answer
x=5
So the answer is x=5.