what is the height of a lamp whose two radii are 20cm and 30cm and slant height is 40cm respectively?

Are you talking about a lamp shade?

Do you want the height of the lamp shade?
Then you are dealing with a "frustrum" , a solid obtained by
cutting off the top part of a cone.

make a sketch of a cross-section of your lampshade.
Extend the slant side on each side so that you have
You should see a small right-angled triangle with base of 20 cm
and a hypotenuse of s, insides a larger right-angled triangle of base 30cm
and a hypotenuse of s+40

By similar triangles ...
s/20 = (s+40)/30
30s = 20s + 800
s = 80

So now you just find the height of the right-angled triangle
with a base of 30 cm and a hypotenuse of 80+40 or 120 cm
let that height be x
x^2 + 30^2 = 120^2
x^2 = 14400 - 900
x = appr 123.69 cm <---- the height of the whole imaginary cone, too big

again we can use a ratio of similar triangles.
topheight/20 = whole height / 30
topheight = 20(123.69...)/30 = 82.46

height of lampshade = 123.69-82.46 = 41.23 cm
(looks reasonable if the slant height is 40 cm)