Step 1: Write the given data.
Diameter of cylinder $= 4$ cm $\Rightarrow$ radius $r_1 = 2$ cm.
Height of cylinder $h = 45$ cm.
Diameter of each sphere $= 6$ cm $\Rightarrow$ radius $r_2 = 3$ cm.
Step 2: Apply the volume formula.
When a solid is melted and recast into other solids, the volumes remain equal. Hence,
\[
\text{Volume of cylinder} = n \times \text{Volume of one sphere}
\]
\[
\pi r_1^2 h = n \times \frac{4}{3}\pi r_2^3
\]
Step 3: Substitute the given values.
\[
\pi (2)^2 (45) = n \times \frac{4}{3} \pi (3)^3
\]
\[
180\pi = n \times \frac{4}{3} \pi \times 27
\]
\[
180 = n \times 36
\]
Step 4: Solve for $n$.
\[
n = \frac{180}{36} = 5
\]
Wait — recheck: \( 4 \times 27 = 108 \), not \(36\). Let's fix properly:
\[
180 = n \times \frac{4}{3} \times 27
\]
\[
180 = n \times 36
\Rightarrow n = 5
\]
Yes, it’s correct.
Step 5: Conclusion.
Hence, the number of solid spheres formed is $5$.