This is not caused by a virus, or any other kind of malware.
Try starting up in safe mode. If the machine starts up fine, but won't start up when you restart normally, then the problem is caused by third-party software you have installed.
If the machine will not start in safe mode, most likely you have a badly corrupt system, and possibly a failing hard drive. You should hold down command-R at startup to boot into recovery mode. From there, open Disk Utility and check the hard drive's SMART status:
If the SMART status says anything other than "Verified," your hard drive is failing. It will need to be replaced. If you don't have any backups, you should immediately make some, which will not be easy.
If SMART status is okay, try repairing the hard drive. The item you will want to repair is below the one you selected to check SMART status, called "Hyperion" in the image above. Probably "Macintosh HD" in your case, unless you have renamed it.
If repairing the hard drive fails, you'll need to erase it and reinstall the system. Again, if you don't have backups, you'll have to figure out how to do that first.
Finally, if all checks out okay, quit Disk Utility and try reinstalling the system. This will reinstall right on top of the existing system, leaving everything else alone. (At least, that's the way it's supposed to work, but because things can go wrong, you ought to have backups before doing this.)
thanks for the replies which helped me resolve issue in boot up I was unable to start in safe mode
I later found out that an avast anti virus programe supposedly for mac was not compataible
i needed to wipe the drive and reinstall mountain lion ox
as I have no data that needed saving this was no problem
one lesson is to be wary of downloading stuff that can cause these problems.
Not sure if mac needs anti virus being a windows convert
old habits die hard