Optimization problem is formulated as a nonlinear constrained minimization problem. The algorithm in MATLAB computes the area of concrete and steel of the sections, by minimizing the overall cost, namely, cost of concrete, steel and formwork. Trial designs of compression members are carried out using the program and the results obtained are compared with those obtained by manual calculations by using MS Excel sheets. Using the results obtained for the design, graphs are drawn to study the influence of grades of concrete and steel on the total cost of axially loaded compression members and the conclusions derived will be useful to the future designers.