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]
3 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]3 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
What is the term for the era created by the digital revolution?<br>​
puteri [66]

Answer:

The Digital Revolution also marks the beginning of the Information Era. The Digital Revolution is sometimes also called the Third Industrial Revolution.

Explanation:

Hope this Helps.

5 0
3 years ago
User Interface Design ensures that the interface has elements that are easy to ________________. (Choose all that apply)
Gnesinka [82]

Answer:

A, C, D

Explanation:

User Interface (UI) Design focuses on anticipating what users might need to do and ensuring that the interface has elements that are easy to access, understand, and use to facilitate those actions.

4 0
3 years ago
Read 2 more answers
Over the past year alone, more than _________ have been stolen from Target.
jasenka [17]
40 million (google said so)
6 0
3 years ago
Read 2 more answers
Assuming arrayName is the name of an array and identifier is a name of a variable that has the same data type as the array eleme
creativ13 [48]

Answer:

The answer is "Option a"

Explanation:

Range-based for loop performs a sequence for a loop. It's more accessible as the conventional loop, for example, all components in the array, running more than a range of possibilities. In the given question "option a" is correct because it follows the correct syntax and other choices were wrong, which can be described as follows:

  • In option b, It's not correct, because in this code the range declaration is wrong.
  • In option c, It is wrong, because in this code the datatype is missing.  
  • In option d, It is illegal syntax, that's why it is wrong.
5 0
3 years ago
How do I change my username/display name
exis [7]

Answer:

.

Explanation:

you do to me on the bottom bar and once you hit that you click the pencil and change it

6 0
3 years ago
Read 2 more answers
Other questions:
  • file Assume that a prototype of the part above was built from several cubes. The total volume of the part is 0.54675 in.3. What
    6·1 answer
  • 4. Who developed the first design technology program which had a
    12·1 answer
  • harry is analyzing inbound network traffic and notices a tcp packet that has the FIN,PSH, and URG flags set at the same time. wh
    8·1 answer
  • Ashley works for a movie theater. The theater has decided to host some special events over the summer. She needs to communicate
    8·2 answers
  • :If a process terminates, will its threads also terminate or will they continue to run? Explain your answer.
    14·1 answer
  • A 9-year old male castrated Westie presents on emergency after being rescued from a house fire. On presentation, the dog has a r
    9·1 answer
  • An IT suspects that an unauthorized device is connected to a wireless network. This is a result of passkey sharing on a device b
    14·1 answer
  • How can presentation software be used in a
    10·2 answers
  • What keys on the keyboard have the ability to move the cursor around on a window?
    11·1 answer
  • Which components must all tasks have? Check all that apply.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!