The cosine function states that cos (x) = adjacent length to the angle/hypotenuse length of the triangle.
the opposite is 24, the adjacent is 32 and hypothenus is 40
hence cos(X) = 32/40 = 4/5.