At higher altitudes there is a greater gain and loss of heat. When you're up high there is also a lower pressure. There are actually fewer molecules in the air. Because there are not as many molecules, there is less matter which can absorb heat. That means the temperatures will change more wildly, from hot to cold, less matter to absorb the heat.
Clouds effect the temperature too.
It's like wearing a windbreaker on a windy day. The jacket traps the heat you give off from your body, keeping it warm between you and the jacket. That's like cloud cover, reflecting the heat given off by the land. The jacket also reflects heat away from you, just like the clouds reflect incoming heat. The thing to know, just like a jacket where some heat gets in and some escapes, the clouds don't reflect and keep all the heat, some of it still passes through.