How can i load a 2D .jpeg/.jpg image and display it using glut of opengl?

How can i load a 2D .jpeg/.jpg image and display it using glut of opengl?
Can anyone post complete example code?

You are asking two completely different questions wrapped into one post.
Loading a texture can be done either by writing a loader yourself or by using some 3rd party image loading utilities.
Why not simply convert the JPG into a BMP or TGA file and deal with that instead - at least then you can put these loders into your own image class. I rely upon my compiler’s runtime libararies to load JPG but BMP,TGA are natively supported in my own code. Honestly, I would not worry about JPG too much as it’s a lossy format (when converted to JPG the image quality is not 100% accurate compared to the original) and nobody truely supports JPG as their first choice of original art.

Using glut to create an opengl program would just be a matter of using Google to find some simple tutorials. Glut does not display opengl images/textures, you need to use OpenGI API functions to do that; again tutorial sites such as HeNe can show you how.

Can you post the complete example code?

No. I don’t program in glut.
You Google and type in GLUT OPENGL TUTORIAL. Unbelieveable!
The very first ‘hit’ = what you want. Lighthouse3d.com has good examples
http://www.lighthouse3d.com/opengl/glut/

Which do you use to load image? Which library do you use to load images?

My primary format is .TGA files. These support 8 bit (greyscale), 16-bit (grey scale), 24-bit RGB, 32-bit RGBA format and can also be optionally compressed.
Dead easy to load uncompressed TGA files - its a 12 byte header followed by the RAW image data.
I don’t use any libraries - I wrote my own TGA,BMP and JPG loader (although JPG is natively supported in Delphi).

How did you write your own loader? Is it available on internet? How do you make .TGA files from png/jpg/bmp?

If you don’t want to write your own loader, then use one of the ones listed over at the Wiki
http://www.opengl.org/wiki/Related_toolkits_and_APIs

If you want to write your own, then you need to figure out the file format from its specification
This site has specs for A LOT of formats :
http://www.wotsit.org

How do you make .TGA files from png/jpg/bmp?

Use an art package like PhotoShop or Paintshop Pro

Is it available on internet?
Yes. Many tutorial sites like HeNe show you how to load TGA or BMp files.

Is the code you wrote available in internet? Did you write the nehe tutorial to load TGA/BMP? What’s special about TGA or BMP? What’s wrong with png,jpg?

Is the code you wrote available in internet?
No.

Did you write the nehe tutorial to load TGA/BMP?
No.

What’s special about TGA or BMP?
Nothing. But they are easy to load! TGA supports alpha channel (32-bit).

What’s wrong with png,jpg?
JPG is a lossy format (meaning when it’s compressed data is lost. It is not 100% identical to the original image. For computer graphics that’s bad!
PNG is better than JPG, but very difficult to load (as in write your own loader class). As I said before, just re save the assets into TGA. Job done.