Ask Question

Determine the output of the following code segment:

int i;

int [] numbers = new int [10];

for (i = 0; i < numbers. length; i++)

{ numbers[i] = 2 * (i - 5); numbers[i] = numbers[i] * numbers[i]; }

for (i = 0; i < numbers. length; i++)

{ System. out. println (numbers[i]);

+1
Answers (1)
  1. 28 June, 17:16
    0
    The output to the given code as follows:

    Output:

    10

    100

    64

    36

    16

    4

    0

    4

    16

    36

    64

    Explanation:

    In the given java code, an integer variable "i" and an array number is defined, which size is 10, in the next step two for loop is declared, that can be described as follows:

    In the first loop, array use loop variable "i" use, which minus the value of 5 and multiplies by 2, and it will calculate the square of that number. In the next step, a for loop is declared, that prints these array number variable square.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Determine the output of the following code segment: int i; int [] numbers = new int [10]; for (i = 0; i < numbers. length; i++) { ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers