This article introduces two numerical methods to address boundary value problems associated with secondorder and fractional differential equations. These methods employ two parameters related to shifted Gegenbauer polynomials as their basis functions. The process involves establishing a differentiation operational matrix for the shifted Gegenbauer polynomials. Subsequently, the initial/boundary value problems for ordinary and fractional differential equations are transformed into a system of equations through the Galerkin, collocation, and tau methods. The convergence analysis is ensured by leveraging theorems pertaining to the shifted Gegenbauer polynomials. To validate the accuracy of the approach, numerous numerical examples are presented.