The general formula for alkanes is CnH2n + 2. Since, an alkene contains two hydrogen atoms less than the corresponding alkane, therefore, the general formula for alkenes is CnH2n.
Further since an alkyne contains 2 hydrogen atoms less than the corresponding alkene, hence the general formula for alkynes is CnH2n _ 2.