Ask Question

Int [] val = { 3, 10, 44 };

int i = 1;

val[i] = val[i - 1];

i++;

val[i] = val[i - 1];

1) 0 1 44

2) 0 2 44

3) 3 0 1

4) 3 3 3

5) 3 0 0

6) 3 3 10

7) 10 44 44

Q2

+3
Answers (1)
  1. 4 March, 04:53
    0
    4) 3 3 3

    Explanation:

    Given data

    int [] val = { 3, 10, 44 };

    The total number of parameters of given array are 3, so total length of array is also 3.

    The indexing of array starts with '0', Therefore the indexes of array with length zero are: {0,1,2}

    The value of array at index 0 is = 3

    similarly

    value at index 1 = 10

    value at index 2 = 44

    Here, Int i = 1 is storing the value '1' in integer variable i.

    In addition to that, any value of index 'i' of an array is selected using array[i].

    Therefore,

    val[i] = val[i-1] is copying the value of index[i-1] that is '0' to the index '1' of the array because i = 1.

    So value at index 1 would be = val[1] = val[0]

    =>val[1] = 3

    The term i+ + is incrementing the value of i, it makes i = 2

    val[i] = val[i-1] is copying the value of index[i-1] that is '1' to the index '2' of the array because i = 2.

    So value at index 2 would be = val[2] = val[1]

    =>val[2] = 3

    Hence, the output would be {3 3 3}. So 4th option is correct.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Int [] val = { 3, 10, 44 }; int i = 1; val[i] = val[i - 1]; i++; val[i] = val[i - 1]; 1) 0 1 44 2) 0 2 44 3) 3 0 1 4) 3 3 3 5) 3 0 0 6) 3 3 ...” 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