(a) Five electrons in the outer subshell means an np5 configuration (ns2np5), i.e. a group 17 element: chlorine (3s23p5); likewise F, Br or I.
(b) An element with two valence electrons, ns2, loses them to form an M2+ ion: a group 2 element, e.g. magnesium ([Ne]3s2→Mg2+); likewise Ca or Ba.
(c) An element with six valence electrons, ns2np4, gains two to complete its octet: a group 16 element, e.g. oxygen (O2−) or sulphur (S2−).
(d) Group 17 (halogens). Fluorine and chlorine are gases and bromine is a liquid at room temperature; iodine is a solid. F, Cl, Br and I are non-metals (iodine only shows a metallic lustre), while the heaviest member, astatine, is radioactive and shows metallic character. So group 17 has gases, a liquid, non-metals and a metallic member.