Add a for loop that will:
generate a number of 1's and 2's as requested by the user
add up the number 1's and 2's generated and store the values in variables numberOfOnes and numberOfTwos
int noOfValues = 0; //user is prompted for this
int value = 0; //randomly generated in the for loop. is either 1 or 2
int numberOfOnes = 0; //number of 1s generated
int numberOfTwos = 0; //number or 2s generated
//prime the random number generator so it is ready to go
srand(time(0));
cout << "Enter the number of values to generate : ";
cin >> noOfValues;
//inside a "for" loop randomly generate a 1 or 2 and count the number of 1's and 2's
//the number of times the loop iterates is determined by the number in noOfValues
In this example you can see it simplifys to the same thing we had above int Temp = rand() % 2;
Use the first example, its the better option, but the second example can be helpful if you wanted a random number between say 50 and 100. It would look like: