If you want to preserve the data on the startup drive, and there is not already a current backup, you must try to back up now, before you do anything else. It may or may not be possible. If you don't care about changes to the data since the last backup, you can skip this step.
There are several ways to back up a Mac that is not fully functional. You need an external hard drive or other storage device to hold the data.
1. Start up from the Recovery partition, or from a local Time Machine backup volume (option key at startup.) When the OS X Utilities screen appears, launch Disk Utility and follow the instructions in this support article. You'll be "restoring" the startup volume to the backup volume.
If you use FileVault 2, then you must first unlock the startup volume. Select its icon ("Macintosh HD," unless you gave it a different name.) It will be nested below another disk icon. Select Unlock from the File menu. Enter your login password when prompted.
2. If Method 1 fails because of disk errors, then you may be able to salvage some of your files by copying them in the Finder. If you already have an external drive with OS X installed, start up from it. Otherwise, if you have Internet access, follow the instructions on this page to prepare the external drive and install OS X on it. You'll use the Recovery installer, rather than downloading it from the App Store.
3. If you have access to a working Mac, and both it and the non-working Mac have FireWire or Thunderbolt ports, start the non-working Mac in target disk mode. If one Mac has Thunderbolt and the other has FireWire, you need a FireWire cable and an adapter. A Retina MacBook (2015 or later model) with a USB-C port can also be started in target disk mode and connected to another Mac using a USB cable and another adapter.
Use the working Mac to copy the data to another drive.
This technique won't work with USB (except on a Retina MacBook), Ethernet, Wi-Fi, or Bluetooth. Note that a Retina MacBook Pro (with Thunderbolt) is different from a Retina MacBook, and it can't be connected to another Mac via USB in target disk mode.
4. If the internal drive of the non-working Mac is user-replaceable, remove it and mount it in an external enclosure or drive dock. Use another Mac to copy the data.