Ask Question
2 October, 11:33

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++;

+4
Answers (1)
  1. 2 October, 14:34
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers