How do i train to be able to slam dunk?
Increase your vertical leap. You will need the lifting power of your legs to get you in the air and up to the basket. Plyometrics are the best (and often fastest) ways to get results. Doing squats, or if you don't have weights, wall sits, also help you gain those inches. Something that also helps is having strong abdominal muscles(Abdominals have little or no effect on jumping. They are stabilizers and do not help with movement). Increasing your height will take time, though, so stick with it.

Muscle groups that need to be stronger: Quadriceps, hamstrings, gluteals, calves. The quadriceps extend the knee. The hamstrings and gluteals extend the hip. The calves plantar flex the ankle.
Muscle groups that need flexibility: Hamstrings and hip flexors. Tight hamstrings will impede the knee extension during the jump. Hip flexors resist the hip extension part of the jump.

Running stairs will develop the quadriceps, hips, and calves.
Invest in a good pair of shoes. Most players find that high-quality shoes improve their ability to dunk, and more importantly, prevent you from getting hurt when you try to dunk.

Practice jumping at the court.
Jump across the whole court and back. Try two laps or more.
Jump to touch the net with a running jump until you are able to do it ten times in a row (not all in one day!).
Progress to the goal of touching the backboard, again until you can do it ten times comfortably.
Set your sights on the rim until you can touch it consistently.

Practice handling the ball. Get a feel for how to use inertia to control the ball when your arm is extended. Even people who can palm a basketball will lose grip when dunking.
Start with an adjustable height basket, if you have access to one. Lower the height so you can get a feel for dunking, then raise it gradually to the standard height as you improve.
Dribble toward the basket, then take the allowed two steps while palming the ball in your dunking hand. Jump as high as you can after your second step, extend your arm to the rim, and drive the ball through the net.
Most people jump off of one foot, but some people find that they jump higher off of two. Find what works for you.
Dunk a tennis ball or golf ball first, then a volleyball, and work your way up to a basketball.
Dunk one-handed first. It helps to find a small sized Basketball to train with. It takes a lot more effort to touch the rim with two hands, because you must jump high enough that both reach the rim. After that, you can progress to the reverse dunk.
The ball may come back and hit you in the face. Be prepared for it. Fear of getting hit will negatively affect your ability to dunk.
Let go of the rim. In most games, hanging on the rim isn't allowed unless you're in danger of landing on someone below you.

Be persistent. You'll likely embarrass yourself during your first several attempts to dunk, but get up off the floor and try again. You'll be impressed at your improvement if you keep going.

Do backboard touches for 2 minutes
Do not over train: Don't exercise the same muscle groups over two consecutive days, for injuries are possible at that time.
Make sure that you have someone else near you when you are learning. If you fall and get hurt without anyone around, you will be in a very difficult situation.
Do not try to grab the rim if you can't wrap your hand around it firmly. If you do you will probably swing around onto your butt, back, neck, head, or your face.
Make sure the rim is securely attached to the backboard or it may come loose. This could result in serious injury.
You are better off not hanging on the rim at all, especially if you are a novice.