Your instructor was correct in that full—or nearly full—nose up elevator trim in the Cessna 172 will give you roughly best glide speed. This is a rule-of-thumb and must be understood as such.
Variances in aircraft CG and even trim rigging render it impossible to make statements such as "X trim setting will give Y speed." And we should note that the best glide speed varies by weight. The Cessna POH or AFM will only give best glide speed for max gross weight.
However, within these limitations, trimming close to full up will get you close. This can be a very helpful rule-of-thumb to get your aircraft quickly trimmed very close to where it should be before fine tuning the trim setting, such that you can glide hands off or with minimal elevator input. This can be very helpful to minimize task saturation when dealing with an emergency, simulated or otherwise.
Now, best glide speed, it should be noted, has a fair margin of error, both positive and negative, in which a change in airspeed will result in minimal change in glide distance. The L/D curve is such that a positive or negative speed variance from best glide speed will give minimal change in lift and drag, generally within a margin of a few knots for an aircraft such as these light Cessnas. For more on this and a visual representation of the L/D curve, see this answer to What is the definition of “best L/D”?. Practically speaking, if you trim full nose up and have the aircraft trimmed hands off to within a few knots of best glide, you are probably doing well. Don't use this as an excuse to be lazy, but don't allow yourself to become fixated either.
I should note that while I have a lot of experience in the 172, I have never flown a 150 0r 152 so I cannot speak to those.