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: 
Any G lens is a D lens. Not all D lenses are G lenses.  

The difference is that a G lens lacks an aperture ring for manually setting the aperture on the lens (rather than the camera). This isn't very important on modern cameras (everything producedin the last 20 years or so) except sometimes in full manual mode it can be more convenient than using the camera controls.  

The reason he advised that lens is not that it's a D rather than a G lens, but because its far wider maximum aperture makes it much more capable in low light situations than the lens you already have (it can capture a lot more light, meaning shorter exposure times). It's also optically far superior to your kit lens, giving better photos with less distortion and lens artifacts. Neither is related to D vs. G, it's just differences in the design and materials used in the lens construction.  

The main reason to omit an aperture ring on many current lenses is cost (it's extra construction, materials, etc.), and there being no space for one on a lens that has VR (the number of contacts on the electronic linking between the lens and body means Nikon could not design a lens that has both VR and an aperture ring without changing their lens mount, which would break compatibility between new and existing lenses and bodies, which they've always avoided).
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.