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
To access documents stored on a "cloud", you'll
gregori [183]

Answer:

B

Explanation:

5 0
3 years ago
Type the correct answer in the box. Spell all words corre ctly.
Andru [333]

Answer:

publication file I think ?

5 0
3 years ago
Read 2 more answers
Mariel types a sentence. She then decides to include that sentence four more times. She then decides she only wants the sentence
Minchanka [31]
CTRL Z and CTRL Y
(undo)_____(redo)
8 0
3 years ago
Read 2 more answers
Approximately how many user accounts were affected by a 2013 hack of the yahoo technology company, which it just announced this
torisob [31]
About one billion user accounts were affected
3 0
4 years ago
John have subscribed to a cloud-based service to synchronize data between your mobile device and your PC. Before allowing the da
xeze [42]

Answer: Mutual authentication

Explanation: Mutual authentication could be referred to a vetting process where the two entities in communication authenticate each other, it could also be referred to as a two-way authentication.

In the scenario above, the cloud service or server authenticates itself with the client and the client authentication itself with the cloud service server by verifying or vetting the certificates of both communicating entities before a secure encrypted connection would be established or created.

8 0
3 years ago
Read 2 more answers
Other questions:
  • How does a saffir put out fires
    12·1 answer
  • Acomputer with a domain name is called a
    8·1 answer
  • write the structure of an email message ques.2 what do you mean by search engine? write its component .ques. 3 what are the adva
    9·1 answer
  • Which best explains a password attached to a document
    9·1 answer
  • _____ can analyze the content of social media communications within the context of a specific brand or product and determine wha
    13·1 answer
  • There are two kinds of type that you can add to a document in Photoshop. You can add
    13·1 answer
  • The arrow next to all programs indicates
    13·1 answer
  • What is the definition of shape
    14·2 answers
  • Identify the two top benefits of using angel investors to start a business.
    6·1 answer
  • Write a C++ program to print name, age, class, school​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!