The Zeeman hyperfine state dependent force in a Stern-Gerlach (SG) experiment has been exploited to separate and detect atoms having different Zeeman hyperfine states in a cold atom cloud. Utilizing this SG technique, we have made the quantitative estimate of atoms in different Zeeman hyperfine states in an atom cloud, which has been helpful in optimizing the optical pumping of atoms for efficient preparation of atomic state. Employing an optimized optical pumping, nearly 92% of cold 87 Rb atoms from a grey magneto-optical trap (G-MOT) on atom-chip have been optically pumped to the trappable Zeeman hyperfine state |F = 2, mF = +2 . These optically pumped atoms have been trapped in an Ioffe-Pritchard magnetic trap near the atom-chip surface.