I'm trying to learn more programming as I progress through and started learning about vectors. What I just programmed here is that, I want the vector array to display random values at the given element input. So if I say I input 6 elements, each element would show random values. But, my program only outputs one random value.
int main(){
vector<int>sam;
cout << "How many elements?";
int num;
cin >> num;
srand(time(0));
for (int i = 0; i < num; i++){
sam.push_back(num);
sam[i]=rand()%100;
}
cout << "The vector array is: " << endl;
for (int i = 0; i <num; i++){
cout << sam[i] << endl;
system("pause");
}
}
How do I make the program show different random values of the given input? Any tip/help is really appreciated :)!