A colonoscopy is a way to view the entire large intestine. The large intestine helps the body process waste. The first 5 to 6 feet of the large intestine is the colon. The last 6 inches of the large intestine is the rectum, ending at the anus.
How a colonoscopy works
A colonoscopy is done with a device called a colonoscope. A colonoscope is a thin, flexible tube with a light and a camera at the end. Before a colonoscopy, the doctor gives you pain medication and a sedative  to reduce discomfort. During the colonoscopy the doctor inserts the colonoscope into the anus and through the colon. The colonoscope captures an image on a video monitor for the doctor to see. It also allows the doctor to remove a small amount of tissue for examination later, called a biopsy .
Doctors use a colonoscopy to find the cause of colorectal problems. It is also used to screen for colorectal cancer  in people who have no symptoms.
Who does my colonoscopy?
Typically, a gastroenterologist performs a colonoscopy with the help of a nurse in a doctor's office or at a hospital. A gastroenterologist is a medical doctor who focuses on the function and diseases of the gastrointestinal system. The gastrointestinal, or GI, system includes the esophagus, stomach, small intestine, colon and rectum, pancreas, gallbladder, bile ducts, and liver. A surgeon may also perform a colonoscopy.
Getting ready for a colonoscopy
When you schedule the exam, your doctor will give you detailed instructions on how to prepare. Tell him or her about all medications you are taking. Also, be sure to ask whether you should take them on the day of the test. In addition, discuss any drug allergies or medical conditions you have.
Your colon must be empty during the colonoscopy. Your doctor will ask you to avoid solid food and to drink only clear liquids for one to three days before the procedure. A liquid diet may include foods such as fat-free bouillon or broth, black coffee, strained fruit juice, or gelatin.
You will also need to take a laxative or give yourself an enema the day or night before the colonoscopy to empty your colon. If your doctor prescribes a laxative, it will be either a pill or a powder that you mix with water before drinking.
Meanwhile, arrange for a friend or family member to drive you home after the procedure because you will be groggy from the sedative. And, check your insurance coverage to see if it covers the medical facility where you will receive the test, the doctor who will perform the colonoscopy, and the anesthesiologist, who will be involved in giving the sedation.
Before the procedure, you will be asked to sign a consent form stating you understand the risks and benefits of the colonoscopy and agree to the test. Talk with your doctor about any concerns you have about the colonoscopy.
During the procedure
When you arrive for your colonoscopy, you will remove your clothing and change into a hospital gown. You will then lie on your side on an examining table in a private room with a sheet draped over your body.
The nurse will give you pain medication and a sedative through an intravenous (IV) line inserted in a vein in your arm. You may feel a slight sting where he or she inserts the needle.
The colonoscope will blow air into your colon and inflate it so the doctor can better see the colorectal lining. As he or she guides the colonoscope through the curves of your colon, you may need to change your position slightly to allow better access.
If there is an abnormal growth, or polyp, in your colon, the doctor will use a tool at the end of the colonoscope to remove it or perform a biopsy. This usually does not cause pain, but bleeding may occur at the site where the tissue is removed. The doctor can stop the bleeding using the colonoscope.
The procedure typically takes about 30 to 60 minutes to complete.
Generally, the pain medicine and sedative you receive before the colonoscopy should limit the discomfort you may feel during the procedure. But you may feel cramping. Taking slow, deep breaths may ease this pain. You may also feel discomfort from lying still for an extended time.
Rarely, the colonoscope may puncture the colon wall, and surgery may be required to repair the hole. Talk with your doctor if you have any concerns about this small risk.
After the procedure
You will stay at the facility where you had the procedure for up to 2 hours afterward. You must wait for the effects of the sedative wear off. If you received anesthesia or a sedative, you should not drive a vehicle, operate any machinery, or make critical decisions for the rest of the day. A friend or family member can then drive you home.
You can expect to resume your normal activities the day after your colonoscopy. However, contact your doctor immediately if you have severe abdominal pain, a fever, bloody bowel movements, dizziness, or weakness.
Questions to ask your doctor
Before your colonoscopy, consider asking your doctor the following questions:
Why do you recommend that I have a colonoscopy?
Who will perform the colonoscopy?
What will happen during the colonoscopy?
How long will the procedure take?
Will it be painful?
Will I receive medications to reduce discomfort?
What are the risks and benefits of having a colonoscopy?
Whom can I talk to about the costs of this test that I may have to pay?
What will happen if I don't have this exam?
Will I need to avoid any activities after the colonoscopy?
When will I learn the results of the test?
Who will explain the results to me?
Will I need additional tests?
Cancer Screening 
American College of Gastroenterology: Colonoscopy 
National Institute of Diabetes and Digestive and Kidney Diseases: Colonoscopy