You can either use the Pythagorean theorem or the formula d = a√2.
Pythagorean theorem:
The diagonal is the hypotenuse of the right triangle in the square and the two sides are the legs.
20² + 20² = d²
400 + 400 = d²
800 = d²
√800 = d
28.28 = d
Using the formula:
d = a√2
d = 20√2
d = 28.28
The answer with both the methods is the same.
Hope this helps :)