Variational principles are derived for single and double-walled carbon nanotubes undergoing longitudinal and radial vibrations and the corresponding Hamilton's principles are obtained. Derivations are based on the strain gradient theory of cylindrical shells which provide a continuum model for carbon nanotubes. Strain gradient theory employed in the present study is a nonlocal elastic theory and as such it is capable of taking small scale effects into account. The variational formulation also enables to obtain the natural and geometric boundary conditions for the problem which lead to boundary conditions coupled in the longitudinal and radial directions. The method of variational formulation uses the techniques of calculus of variations and the semi-inverse method of deriving the variational integrals for problems governed by a system of differential equations. Variational formulations provide the basis for a number of approximate and numerical methods of solutions.