The words pasta and pasto are very close in terms of sound and spelling, but that’s where the similarities end.
The feminine singular noun pasta is pronounced PAH-stah. La pasta has five (count ’em five) main definitions:
1 dry or fresh noodles, made from grain flour and water, sometimes with egg or other additions, of any shape and size
2 dough, of any kind, for noodles, bread, pizza, etc.
3 a small pastry, synonymous with un pasticcino
4 a pasty substance (such as pasta di mandorla [almond paste])
5 nature or character: if someone says you have a pasta buona, that means you have good character
Il pasto, however, is a masculine singular noun pronounced PAH-stoh and only has two main definitions:
2 a general term for food, synonymous with il cibo
You can eat la pasta for un pasto, but it doesn’t work the other way around.
La pasta and il pasto also have different roots: la pasta comes from the late Latin term păstam, which means dough. Il pasto comes from the Latin verb pascĕre, which means to feed or to graze.
Just like la pasta / il pasto, there are a few more foodie terms that have different meanings in different genders: il tavolo / la tavola l’arancio / l’arancia il melo / la mela il pesco / la pesca
Most of these terms are covered in Italian Through Food. You can also find an explanation of how these words work (in Italian) here, or look them up in a bilingual dictionary.
If this is the kind of learning you like to do, pick up a copy of Italian Through Food!