225k views
0 votes
Your main function for phase I must look exactly like this:

int main()
{
srand(time(0));
doOneSet();
}

You must write the function doOneSet which will, for now, write out 5 addition problems. All of the numbers in your programs should be between 0 and 100. Here is the sample output for this phase:

45 + 21 =
0 + 100 =
54 + 23 =
4 + 19 =
8 + 92 =

The numbers that are produced for these problems must be generated randomly by the computer. The numbers in the sample output are given only as an example. We will discuss in the lessons how to generate random numbers.

1 Answer

3 votes

Answer:

void doOneSet(){

int number1, number2;

for (int i = 0; i < 5; i++){

number1 = rand() % 101;

number2 = rand() % 101;

cout << number1 << " + " << number2 << " = " << endl;

}

}

Step-by-step explanation:

Create a function called doOneSet that takes no parameter

Declare two numbers that will be used as operands

Create a for loop that iterates five times. Inside the loop, produce two random numbers between 0 and 100 in each iteration using rand(). Print the numbers with "+" between them in each iteration to get the required output.

User M Karimi
by
4.4k points