Lambert's Cosine Law: It states that the intensity of light on a diffuse surface is directly proportional to the cosine angle θ between the incoming light ray and the unit normal to the surface.
In layman's language, if the angle is low light intensity is low and if angle is high intensity is high.
Hence, applying lambert's law in ray tracer code will give diffuse lambertian surfaces.
float lambert = (lightRay.direction * normal) * coef;
Images generated after its application: (although shadows seem wrong)