We investigated the size and temperature dependence of the energy gaps in H-terminated Si, SiC, and C quantum dots with diameters ranging from 1 to 10 nm, using tight-binding molecular dynamics (MDs) simulations. For the quantum dots with more than 1000 atoms, the order-N Krylov subspace method was employed. From our results, we formulated the energy gaps of the quantum dots as a function of their size and temperature. Our formula is applicable to the estimation of the energy gaps at any given temperature in the 0-600 K range, for a wide variety of quantum dot sizes (from a small quantum dot to bulk). The calculated energy gaps were in good agreement with the experimentally measured values. The thermal fluctuations of the band gap for a Si quantum dot were also analyzed in detail. We found that, unlike the case of bulk, the decrease in the energy gap at higher temperatures is predominantly caused by an increase in the splitting of the HOMO levels, with only a small contribution from the size expansion effect. For the temperature dependence of the energy gap of Si quantum dots, we also examined the effect of the media surrounding the quantum dots by performing tight-binding MDs simulations at finite temperatures with and without the restriction on the freedom of the motion of the surface H atoms. Our results have clarified that the temperature dependence of the energy gaps of quantum dots in a medium with weak restrictions on the freedom of the surface atomic motion (e.g., in gas or liquid) is larger than in a medium with strong restrictions (e.g., like SiO 2 ), especially in the case of small quantum dots.