In this research, the continuous adjoint method is applied to optimize an airfoil in subsonic and transonic flows. An inverse design problem is solved to evaluate the ability of the optimization algorithm and then, two types of optimizations, constrained and non-constrained, are investigated in a drag minimization problem. In the non-constrained drag minimization problem, the optimization is performed in a fixed angle of attack with neither geometric nor aerodynamic constraint, but in the constrained drag minimization problem, the optimization is performed in a fixed lift coefficient. Comparison of the results of these two optimizations shows the effects of the constraint on the optimization trend and the optimized geometry. Moreover, imposing the aerodynamic constraint increased the computational costs of the adjoint method. In constrained and non-constrained drag minimization problems, the surface points are adopted as design variables to show the performance of the adjoint equations approach in problems with numerous design variables.