The general molecular formula of alkenes and alkynes containing ‘n’ number of carbon atoms is CnH2n and CnH2n-2.
Using this one can see that,
Alkenes: C6H12, C2H4, C4H8
Alkynes: C3H4, C5H8
Note that molecular formula alone is not sufficient to uniquely identify a compound. For example, C6H12 can mean hexane (unsaturated hydrocarbon) as well as cyclohexane (saturated cyclic hydrocarbon).