Can anyone help please.
i am creating a code will randomly create the list of N integers (from 4 – 56).
The value N will be input by the user.
But when i run this code, it have same amount of zero as the user input.
If N is equal to 5. You create a list, called Second of size 5, and I guess it initializes them all to 0.
1 2 3 4 5
for(int i=0; i<5; i++)
{
int x = 4+rand()%52;
Second.push_back(x);
}
Why does this for-loop run 5 times? Shouldnt it run N times? And since you're filling the list here with N integers, there is no need for list<int>Second(N); Just change it to list<int>Second;