Ask Question

What does the following code do? Assume "list" is an array of int values, "temp" is some previously initialized int value, and "c" is an int initialized to 0. for (int j=0; j < list. length; j++) if (list[j] < temp) c++;

+3
Answers (1)
  1. 27 August, 20:48
    0
    Counting the number of elements in the array list smaller than temp.

    Explanation:

    We have an array list, a previously initialized integer temp and a an integer c initialized with 0.

    In the code a for loop is used to iterate over the array and it is checking if the element at jth index is less than temp if it is then increasing the variable c by 1.

    Hence when the loop ends the c will be having the count of the integers in array list that are smaller than temp.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What does the following code do? Assume "list" is an array of int values, "temp" is some previously initialized int value, and "c" is an ...” 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