Let us say Reena has P number of pens and N number of pencils.

As the total number is 40 , P + N = 40

N = 40 - P ---- equation 1

If she has 5 more pencils, it means number of pencils = N + 5

If she has 5 less pens, it means number of pens = P - 5

Then number of pencils becomes 4 times the number of pens. That is,

N + 5 = 4 * (P - 5)

so N + 5 = 4 P - 4 * 5 = 4 P - 20

so N = 4 P - 25

Substitute N = 40 -P from equation 1,

N = 40 - P = 4 P - 25

40 + 25 = 4 P + P or 65 = 5 P

P = 13

from equation 1, N = 40 - P = 27

She has 27 pencils and 13 pens.