It is normal to have some air in the digestive tract (the esophagus, stomach, small intestine and large intestine) as some air is swallowed while the process of digestion produces some air.  Many people think that they have too much gas when they really have normal amounts.  Most people produce 1-4 pints of gas per day and pass gas about 14 times per day.
The air that is swallowed may be from eating or drinking rapidly, carbonated beverages, gulping, gasping, sighing, talking, chewing gum and smoking.  Burping is the way that most air leaves the stomach.  The air that is left will travel through the digestive tract until it is released as flatulence.
The breakdown of carbohydrates in the digestive tract such as sugars (lactose from dairy, fructose from fruit and fruit juice), starches (potatoes, corn, noodles, grains) and soluble fiber foods (beans, peas, fruits and oat bran) will lead to an increased production of hydrogen, carbon dioxide and methane gases that need to leave the body through the rectum.
The most common ways to reduce gas is to drink beverages slowly, do not use a straw, chew with your mouth closed, and limit conversations when eating and change your diet.
In order to change your diet, you first need to identify the foods that are causing you gas.  Because the amount of gas produced varies from person to person, you will need to keep a record of what you eat.  This will help you to determine which foods cause the gas and then you can vary the amount of that food you eat to see how much you can tolerate.  For example, if lactose intolerance (lactose is a type of sugar found in milk products) is suspected of causing the gas, you will probably have to limit your consumption of dairy products and/or take the enzyme lactase (caplet or chewable tablet) just before eating dairy foods.
Some doctors may suggest limiting foods that cause gas but this may mean that you are cutting out healthy foods such as fruits, vegetables and whole grains.  You want to be able to eat a healthy diet, one consisting of a variety of foods so keep a food journal, identify the offending food(s) and learn how much you can tolerate.
You may also want to look at your total intake of sugar alcohols as these can contribute to abdominal gas, bloating and diarrhea.