Ask Question

Suppose list is a one dimensional array of size 25, where in each component is of type int. Further, suppose that sum is an int variable. The following for loop correctly finds the sum of the elements of list.

+4
Answers (1)
  1. 17 February, 17:05
    0
    False is the correct answer to the following question.

    Explanation:

    In the following question there some information is missing code is missing which is 'sum = 0;

    for (int i = 0; i < 25; i++)

    sum = sum + list;

    (T/F) '

    The following code is incorrect because this is not the right way to add the elements of an array, the correct code is:

    int sum=0;

    for (int i = 0; i < 25; i++)

    {

    sum = sum + list[i];

    }

    In the following code block, we add each elements of an array and the addition is save into the variable "sum"

    So, that's why the following code is incorrect.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Suppose list is a one dimensional array of size 25, where in each component is of type int. Further, suppose that sum is an int variable. ...” 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