The energy contained in most carbohydrate molecules ultimately originates from photosynthesis in plants. Most carbohydrates thus get their energy from the sun.
lipids contain much more energy then carbohydrates. One gram of lipids create an average of 423 ATP or 0.47 mol ATP/gram. Glucose, with a molecular weight of 180.16, generates only 36 ATP, or 0.20...
Carbohydrates are the primary energy source for herbivores (cows, horses, etc.). Proteins are the primary energy source for carnivores (dogs, cats, etc.).