Many optimization problems involve inequality and/or equality constraints and thus posed as constraint optimization problems. To solve constraint optimization problems using genetic algorithms (GAs) or classical optimization methods, penalty function methods are commonly used because of their ease of implementation. Although the penalty function approach is applicable to any type of constraint (linear or nonlinear), however, its performance is not always satisfactory. Thus, researchers have developed penalty functions specific to the problem and search algorithm for the optimization. The most difficult aspect of penalty function approach is to provide suitable values to parameters so that the penalty function can guide the algorithm towards the constraint optimum. In this paper we propose a penalty function which involves exponential function using two penalty parameters with small positive integral ranges. This penalty function handles almost automatically very large and very small violations. GA with this penalty function has been tested on four problems which are solved by researchers using different penalty functions. In all cases, the proposed penalty function approach has been able to provide solutions that are comparable with the solutions obtained through penalty functions available in the literature.