Complementary angles are two angles that add up to 90 degrees. Given that one angle measures 40 degrees and the other measures \(8x + 2\), we can set up the following equation:
\[ 40 + (8x + 2) = 90 \]
Now, simplify the equation:
\[ 40 + 8x + 2 = 90 \] \[ 8x + 42 = 90 \]
Next, subtract 42 from both sides:
\[ 8x = 90 - 42 \] \[ 8x = 48 \]
Now, divide by 8:
\[ x = \frac{48}{8} = 6 \]
Thus, the value of \(x\) is 6.