Hello,
Welcome to ehealthforum and thanks for writing
According to the symptoms described by you as constipation altered with loose stools sometimes and pain abdomen can be suggestive of Irritable bowel disease.Some other causes can be celiac disease, crohn's disease, malabsorption syndromes, pancreatic diseases, diabetes, hyperthyroidism etc.
The precise diagnosis can be made only after a physical examination and investigations as Endoscopy/colonscopy,USG scan,blood tests etc.
You can try these tips which might help you:
1)Eating smaller meals may lessen the incidence of cramping.
2)Dietary fiber may lessen symptoms.You should drink plenty of water, and avoid soda, which may cause gas and abdominal discomfort.
3)Low fat and high carbohydrate meals such as pasta, rice, and whole grain breads may help IBS symptoms
4)Drink lots of water and restrict smoking,soda,caffeine use.
5))Diet should include fresh fruits, fiber rich foods.It is very important to take fibre rich diet as cereals,bran,beans,dal,oats,whole grains as it helps in softening stool.
6)Adopt proper posture and if you have long sitting hours work take small breaks and stretch the body.
7)Do some form of exercise even a daily walk is fine.
If your condition does not improve then I suggest you to get an examination and investigations like colonoscopy, nerve conduction velocity and ultrasound done to confirm the diagnosis. You need to consult a surgeon for the physical examination.
Take care!