The simplest solution would be to startup you Mac from a System on an external drive, if you do have a bootable external drive. If not, then Perform Apple Diagnostics as outlined in this article: OS X El Capitan: Use Apple Diagnostics or Apple Hardware Test
Other options...
First, restart your computer while holding down the Shift key. This will boot your iMac into Safe Mode, which bypasses any extensions or startup items that might be causing a problem. Safe Mode takes much longer to boot, so give it time. If the Mac boots, you have a software conflict and need to remove startup items and extensions in order to isolate the bad one. It is also a good idea to disconnect all external drives and other accessories while doing this.
If that doesn't help, you need to boot into Recovery Disk by holding down the Command + R keys while starting up. This will give you access to Disk Utility, which you can then use to verify and repair your main hard drive. See OS X: About OS X Recovery - Apple Support