Answer: 7 cm
===========================================================
Step-by-step explanation:
x = side length of the original square (measured in cm).
One side increases by 8 cm to go from x to x+8. At the same time, an adjacent side decreases from x to x-2 (aka it decreases by 2 cm).
The x by x square turns into a x+8 by x-2 rectangle.
L = x+8 = length
W = x-2 = width
P = perimeter of rectangle
P = 2(L+W)
P = 2(x+8+x-2)
P = 2(2x+6)
P = 4x+12
The perimeter of this rectangle is 4x+12, which is set equal to the stated perimeter 40 cm. We'll use this to solve for x.
P = 40
4x+12 = 40
4x = 40-12
4x = 28
x = 28/4
x = 7
The square originally had side lengths of 7 cm.
Increasing this by 8 cm gets us x+8 = 7+8 = 15 cm. So L = 15.
Also, W = x-2 = 7-2 = 5 cm is the width.
Then note how P = 2(L+W) = 2(15+5) = 40 to help confirm the answer.