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: 
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.
50mm 1.8 d has no auto focus motor. If you want to auto focus with this lens use d7000 or higher because this camera has built in auto focus, use 50mm 1.8 G if you want auto focus to the camera d5000 below. Because 50 mm 1.8 G is designed for cameras d5000 and below for auto focus. Ok