Hello can someone please tell me what I'm doing wrong? I am trying to compute the total amount of food but for some reason it's coming out as 1517695209 which is way too much it should be around 4200.
You read in 35 values, but you then add up 101 values (which seems odd in itself, since your array only has 100 elements - I suspect you meant for(int i = 0; i < 100; i++). All the elements you have not written into will have some random number in them.
You must add up ONLY the elements you have stored a value in.
You misunderstand what (conventional, standard PC) memory is. There is no such thing as blank memory. Memory has a physical reality; it is real, it has a physical state that represents data, it can never be "blank".
The variables you use in your program ultimately are stored in physical memory, and thus they, too, can never be "blank".
When you allocate an array, every element in that array (you know where this is going) is ultimately stored in memory and can never be "blank". Every element in your array will have some value. There is nothing you can do about this. It is up to you to keep track of which elements you actually care about, and which elements you do not.
Since you're adding the elements, if you simply set every element to zero at the start, you'd not have to worry about adding elements you weren't using - they'd have a value of zero.
Thank you, Since you seem pretty smart can you help me with my other question? No one has answered but I really need help. Thanks for your time. Here's the link if you feel like helping out: http://www.cplusplus.com/forum/beginner/63414/