In this work, a new approach is proposed to solve cooperative localization problems in wireless sensor networks for both one-hop and multi-hop cases. To find the unknown positions of randomly distributed sensors with limited power and communication ability, noisy inter-sensor distances and anchor node positions are used. In a plane, when the distances between a sensor and at least three neighbor anchors are known, it is possible to find the sensor position by solving a linear set of equations. However, for networks having few number of anchors, the problem becomes a non-convex optimization problem and it is NP(Nondeterministic-polinomial) hard. In this paper, alternating minimization algorithm is proposed to overcome this difficulty. With this approach, the non-convex localization problem is converted into a convex form and it converges to the optimum solution being solved iteratively. Different problem scenarios are considered and effectiveness of the proposed approach is shown by considering several experiments.