hi i having some problem i am using lm35 to control household fan as my fyp. when i set the temperature above 20 degree it turn on the fan. when actual the fan doesn't turn on having different result each time i upload the program but if i use pc fan no problem is works perfectly well. i connect the fan using a relay
That is the worst thing you can do. The relay should be switched with a NPN transitor (with proper resistors too), have a feedback diode and be on its own separate power supply (with a common ground -> Arduino ground to Ext power ground)
*Actually the worst thing you can do is power the relay from another digital pin.