Difference Between Fruit and Vegetable?

I’m wondering what the difference between fruit and vegetable is.
I know Tomato is a fruit, and carrot is a vegetable, i want to know why tomato is a fruit? Is it because of the seeds? If it is, Why isn’t a Pumpkin a fruit? Or Cucumber? Or capsicum even?
What makes tomato be a fruit, while the other vegetables with seeds are vegetables?
It can’t be the way they’re grown either. Tomato grows on a vine, but so do beans and peas. Pumpkin grows sitting above the ground, but so does watermelon.