Question: I recently bought a Nikon D5100. And along with this camera, I got the AF-S DX NIKKOR 18-55mm f/3.5-5.6G VR lens as kit. It's "G" type lens, right?

One of my friend suggested to buy a 50mm f/1.8D prime lens for a good aperture. I bought it too, and it's "D" type lens.

Main thing is I'm confused about what these "G" and "D" type lens means. I know it's a common question but I didn't find any solid answer.

Answer: 
Here is the description from Nikon's own web site:

**D-Type NIKKOR Lenses**
A D-type lens relays subject-to-camera-distance information to Nikon D-SLRs that feature 3D Color Matrix Metering (all versions), 3D Matrix Metering, 3D Multi-Sensor Balanced Fill-Flash and i-TTL Balanced Fill-Flash. Many D-Type lenses have an aperture control ring and can be used on older Nikon SLR cameras that allow for manual control of the aperture, as well as on D-SLRs—especially useful for adjusting aperture while recording D-Movies on higher end models. When used on a D-SLR, the aperture control ring needs to be locked at the smallest possible aperture (generally designated in orange), and the aperture control is maintained through the camera's command dial

**G-Type NIKKOR Lenses**
A G-type lens does not have an aperture control ring and are intended for use on Nikon D-SLRs that allow the lens aperture to be adjusted via the camera's command dial. Because G-type lenses relay subject-to-camera-distance information to the camera, where it is used to help determine ambient and flash exposure, they are also considered to be D-type lenses. The lack of an aperture control ring is perhaps the easiest way that you can tell if a lens is a G-Type NIKKOR or not. [The AF-S NIKKOR 24-120mm f/4G ED VR lens, shown above is an example of a G-Type lens. Note there is no aperture ring on that version of the lens, while there is an aperture ring on the AF version, above right.]

<http://www.nikonusa.com/en/Learn-And-Explore/Article/go35b5yp/which-nikkor-lens-type-is-right-for-your-d-slr.html>

To me the main different is that a G lenses are newer lenses where Nikon have removed the aperture ring.
You commented that you cannot focus automatically on your kit lens. There should be a switch on the lens which you can use either for Auto or Manual focus - marked A and M. Set this to A for auto-focus. On the auto dial, set your camera to Auto mode and check auto-focus. 

If you are using the camera in other modes (as per the command dial) such as Aperture or Manual, there is an option inside the camera also to switch between Auto-focusing and Manual-focusing. You will also be able to select the focus mode and focus-points by pressing the "i" button on the camera and changing the options available on the LCD screen.

The best way to know/learn this is to go through the camera manual which provides these instructions along with illustrations. If you are still not able to auto-focus after setting all these options, then you need to take the camera back to the shop or service-center for getting it checked.