We simulate the electromechanical behavior of freestanding and clamped carbon nanotubes (CNTs) subjected to an electric potential and displaying charge end enhancements. In this case, CNT deformation is a consequence of the electrostatic pressure associated with the charge density. Whereas experiments investigate several micron long CNTs, computational models consider nanometer-sized CNTs. Hence, experimental and computational results, often, cannot be compared. Analytical solutions appear thus useful as reference solutions for finite element analysis, alternative to atomistic simulations, and complementary to experimental tests. In this work, the electromechanical behavior of CNTs is computed by using the nonlocal Poisson equation obtained extending the charge transport equations for spatially variable currents. Based on a certain equivalence between gradient and integral formulations, we solve the problem governing the electromechanical problem of CNTs regarded as cylinders subjected to electrostatic forces. The present procedure automatically captures charge end enhancements, thus overcoming the necessity of introducing suitable charge end correction factors. The analytical expressions of the radial displacement of freestanding CNTs, and the deflection of bent CNTs are obtained. For armchair single wall CNTs, the results obtained are consistent with experiments, and molecular mechanics and atomistic simulations. Size dependence of electric and mechanical properties is assessed