Question 469112
Let x is the height of a rectangle
If the width is 8 inches longer than the height, then the width is {{{(x+8)}}} inches
Use the Pythagorean theorem 
{{{x^2+(x+8)^2=40^2}}}
{{{x^2+x^2+16x+64-1600=0}}}
{{{2x^2+16x-1536=0}}} divide by 2
{{{x^2+8x-768=0}}}
{{{x = (-b +- sqrt( b^2-4*a*c ))/(2*a) }}}
{{{x = (-8 +- sqrt(8^2-4*1*(-768) ))/(2*1) }}}
{{{x = (-8 +- sqrt(3136))/2 }}}
{{{x = (-8 +56)/2=24 }}} inches is the height of a rectangle
{{{x = (-8 -56)/2=-32<0 }}} the extraneous root 
The height of a rectangle is 24 inches, the width is 24+8=32 inches
Answer: 24 inches, 32 inches