Not only this is possible, but there is whole field in computing activity called GPGPU: General-purpose computing on graphics processing units — Wikipedia, the free encyclopedia
Of course, this approach is one of the weird paradoxes of technological development in the computing world: the technologies initially designed purely for serving displays are now sometimes used for serving up the general-purpose calculations, providing more computing power than the host system's CPUs. However, in real practice this approach is used in a number of areas. Notably, the application leveraging the power of GPUs, still allow them to show graphics on screen, in parallel to the GPGPU operation.
One of the most used technologies of this sort is NVIDIA CUDA:
CUDA — Wikipedia, the free encyclopedia
Parallel Programming and Computing Platform | CUDA | NVIDIA|NVIDIA
As to the code samples, few code sample from few Quick Answers
hardly can help you. You have to learn this field well, to understand how to use it. For CUDA, for example, you can find a lot of material, and even study courses with code samples and homework assignments, like this one: CS 179: GPU Programming
You need to study the subject independently, to a reasonable depth, to be able to ask more specific and qualified questions.