So I'm new to programming and we have an assignment that is to populate an array of 100 elements with random values between 100 and 1200. I can't find out how to get the random values to fill the array. This is what I have so far:
Any help would be greatly appreciated. I can't find any answers in my book or online so far. I'm using Visual c++ express and I'm getting an error coming up for the word "rand" in the "for" loop.
In our class I was told that doing rand()%(max-min +1)+min as a way to generate random number between a given range. Also I only declared double rand() as a way to see if it would remove my error from the compiler. So if I use (rand ()%1200)+1 how would it know what my minimum range value is. I can't add any numbers less than 100 to the array.
Well in your case you don't have a minimum range outside of 1, which is what the +1 is for, but you don't have it encapsulated in a function so the whole 1200 - 100 + 1 is quite useless...