Vinegar and table sugar are different compounds made up of the exact same elements - carbon, hydrogen and oxygen. Their formulae are as follows:
Vinegar = acetic acid = `CH_3COOH`
table sugar = sucrose = `C_12H_22O_11`
They have very different properties because they contain different numbers of these atoms and because they are put together in different ways. There are 92 naturally occuring elements that make up over 10 million different compounds. Of these, nearly 9 million are organic, meaning they contain carbon and hydrogen. Organic compounds often contain oxygen as well.
Structure is at least as important as formula in determining the chemical and physical properties of a compound. There are organic compounds that have the same formulae but different properties because they have different structures. Acetic acid has the functional group -COOH, in which one oxygen is double bonded to the carbon and the other oxygen is single bonded to the carbon and single bonded to the hydrogen. This hydrogen can be lost as an H+, so this structure gives the molecule its acidic behavior. Sucrose is a disaccharide, which is two simple sugars bonded together. It shares characteristics with other disaccharides as they have similar structures.