Can anybody tell me how to apply color gradients to objects in opengl??

Could you define what you mean by gradients?

You can set different colors on vertices of a surface, and have the hardware blend between them as it fills the triangles. You can also use texturing to do color gradients across surfaces.

gradients are special type of fills for shapes that create ramp of colors that interpolate between two or more fixed colors.

can u send sample code if any??

Try here