Answer:
0
Step-by-step explanation:
Given the code segment:
- int product = 1;
- int max = 20;
- for (int i = 0; i <= max; i++)
- product = product * i;
-
- System.out.println("The product is " + product);
Since the counter i in the for loop started with 0, and therefore product * i will always be 0 no matter how many rounds of loop to go through.
The code is likely to perform factorial calculation. To do so, we need to change the starting value for the counter i to 1.
- int product = 1;
- int max = 20;
- for (int i = 1; i <= max; i++)
- product = product * i;
-
- System.out.println("The product is " + product);