if number of sides are s,
The number of diagonals D = s(s-3)/2
by solve this equation 40 = s^2-3s
By solve this we get s = 8, -5
so the number of sides are 8
"The gaming of numbers is called maths.So participate in this wonderful game and explore in it,learn in it and enjoy in it.Then only you can pass in this wonderful game."