When I draw triangles using the following codes, the edges which are the intersection of two triangles are not shaded smoothly. The edges are shaded like saw. Please let me know
how to make shading triangles smoothly.

Sawtooth shaped intersections normally occur if your depth buffer precision is too low.

In the pixelformat request a depth buffer with 24 bits.

Use a projection setup which encloses the object you draw with the zNear and zFar planes as close as possible, that is, make the ratio of zFar/zNear as small as possible by pushing zNear out and zFar in.