Answer:
B) 27.3 m
Explanation:
The rock describes a parabolic path.
The parabolic movement results from the composition of a uniform rectilinear motion (horizontal ) and a uniformly accelerated rectilinear motion of upward or downward motion (vertical ).
The equation of uniform rectilinear motion (horizontal ) for the x axis is :
x =  vx*t   Equation (1)
Where:  
x: horizontal position in meters (m)
t : time (s)
vx: horizontal velocity  in m/s  
The equations of uniformly accelerated rectilinear motion of upward (vertical ) for the y axis  are:
(vfy)² = (v₀y)² - 2g(y- y₀)    Equation (2)
vfy = v₀y -gt     Equation (3)
Where:  
y: vertical position in meters (m)  
y₀ : initial vertical position in meters (m)  
t : time in seconds (s)
v₀y: initial  vertical velocity  in m/s  
vfy: final  vertical velocity  in m/s  
g: acceleration due to gravity in m/s²
Data
v₀ = 30 m/s , at an angle  α=40.0° above the horizontal
v₀x = vx = 30*cos40° = 22.98 m/s 
v₀y = 30*sin40° = 19.28 m/s
y₀ = 2m
y =  18.0 m
g = 9.8 m/s²
Calculation of the time (t) it takes for the rock to reach at  18 m above the ground
We replace data in the equation (2)
(vfy)² = (v₀y)² - 2g(y- y₀)    
(vfy)² = (19.28)² - 2(9.8)(18- 2) 
(vfy)² = 371.86 - 313.6
(vfy)² = 58.26

vfy = 7.63 m/s
We replace vfy = 7.63 m/s in the equation (2)
vfy = v₀y - gt 
7.63 = 19.28 - (9.8)(t) 
(9.8)(t) = 11.65
t = 11.65 / (9.8)
t = 1.19 s
Horizontal distance from where the rock was thrown to the window
We replace t = 1.19 s , in the equation (1)
x =  vx*t  
x = (22.98)* ( 1.19 )
x = 27.3 m