1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Wewaii [24]
4 years ago
13

What does the following fragment of code display? What do you think the programmer intended the code to do, and how would you fi

x it? int product = 1; int max = 20; for (int i = 0; i <= max; i++) product = product * i; System.out.println("The product is " + product);
Computers and Technology
1 answer:
postnew [5]4 years ago
8 0

Answer:

0

Explanation:

Given the code segment:

  1.        int product = 1;
  2.        int max = 20;
  3.        for (int i = 0; i <= max; i++)
  4.            product = product * i;
  5.        System.out.println("The product is " + product);

Since the counter i in the for loop started with 0, and therefore <em>product * i </em>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.

  1.        int product = 1;
  2.        int max = 20;
  3.        for (int i = 1; i <= max; i++)
  4.            product = product * i;
  5.        System.out.println("The product is " + product);

You might be interested in
Your sister has just emailed you an attached file with the invitation list for her upcoming party.
Andreyy89

Answer:

The file Extension so the answer is C

5 0
3 years ago
Read 2 more answers
PLS HURRY!!!<br> Look at the image below!
max2010maxim [7]

Answer:

Ctrl+c

Explanation:

6 0
3 years ago
Read 2 more answers
For most people, the most effective way to save is:
oksian1 [2.3K]
I would say it's by creating a spending budget. 
3 0
3 years ago
. What part of the communication feedback loop results in unclear communication? A. Sender's message B. Interference C. Message
MakcuM [25]
D is ur final answer i hope i helped
7 0
3 years ago
Read 2 more answers
I need help making a rap song of my own !! Ty
Veronika [31]
What are u making it about?
6 0
3 years ago
Read 2 more answers
Other questions:
  • 1. When you write HTML code, you use ______ to describe the structure of information on a webpage. a. a web address b. tags c. s
    6·1 answer
  • In what stage of writing does publishing occur
    14·1 answer
  • program that reads numbers from scanf (keyboard) and then sums them, stopping when 0 has been entered. Construct three versions
    14·1 answer
  • Developers and organizations all around the world leverage ______ extensively.
    9·2 answers
  • Arrange the types of movies in terms of the amount of content they can hold
    14·1 answer
  • The derivative of <br><img src="https://tex.z-dn.net/?f=ln%20%5C%3A%20%20%7Cx%7C%20" id="TexFormula1" title="ln \: |x| " alt="l
    7·2 answers
  • FRQ: Hotel Rooms Part A &amp; B Edhesive
    10·1 answer
  • Write an essay about yourself based on the dimensions of ones personality​
    9·1 answer
  • 10. Two technicians are discussing recycling specifications for refrigerant. Technician A says that refrigerant oil with 5,000 p
    9·1 answer
  • your own choice Identify an organisation of whether factual of fiction with the following Consideration:The three best os to int
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!