1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Kryger [21]
3 years ago
15

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++;
a. It finds the smallest value and stores it in temp
b. It finds the largest value and stores it in temp
c. It counts the number of elements equal to the smallest value in the list
d. It counts the number of elements in the list that are less than temp
Computers and Technology
2 answers:
BigorU [14]3 years ago
6 0

Answer:

Option D is correct.

Explanation:

Option D is correct because  when the condition  if (list[j] < temp) is tested it only gets true when element in list[] array at <em>jth</em> position is less than the value in <em>temp</em> and after that it increments the value of c by this statement: c++ and so c is incremented from 0 to as much times as much elements in list[] are lesser than temp.

neonofarm [45]3 years ago
4 0

Answer:

d) It counts the number of elements in list that are less than temp        

Explanation:

Lets have a look at the code fragment.

There is a loop variable j which starts from then moves through the array length.

This loop will continue to execute till it reaches the end of the list.

Also the value of j will be incremented by 1 at the end of every iteration.

The variable c will also be incremented by 1 every time the if condition evaluates to true.  

Lets say that temp= 5 c=0 and list has the following elements: 1 2 3 4 5 6

In the first iteration the value of j=0 which is less than array length as array length is 6.

So the control enters the loop body, if statement is checks if the jth index of array is less than value of temp?

   Here list[j]=list[0] = 1

As the value of j is 0 and the element at 0 th index of array is 1

So the condition is true because 1 is less than the value of temp i.e. 5

After this the statement c++ is executed which will increment value of c by 1 so c=1.

So this loop will iterate till the end of the list is reached.

At every iteration it will be checked if the element in the list is less than the value of temp and c will keep counting the number of times this condition evaluates to true.

So it is clear that this code counts the number of elements in the list that are less than temp.

You might be interested in
What does in-private or incognito browsing do?
Aleks04 [339]

All it does it let you browse the internet, but whatever you look up, it isn't put on your browser history.
5 0
2 years ago
What some one ask me if i am more of hardware or software person, what is that mean?
balu736 [363]

Answer: Any person or people asking about someone being a hardware or software person displays that they are questioning about the computer knowledge of the person and his/her interest.

The interest can be regarding software tools for programming, designing ,  etc or hardware device like troubleshooting, assembling the computer parts ,etc.

The person persisting good knowledge about software programming language and software is diverted towards software side .The person who likes to deal with hardware parts of the computer system is hardware-oriented person.

7 0
3 years ago
) Which of these will not select all the cells in a document?
dolphi86 [110]
Pressing enter two times I’m pretty sure that’s right cuz like it does nothing when I do it. It’s either that or idk up to u to take an answer from someone who has bad grammar
4 0
2 years ago
Imagery functions as a coding system to help individuals acquire movement patterns. this describes
denis-greek [22]

Answer:

Imagery can be used to develop qualities in yourself you'd like to have — it's like emotional body-building — and using a technique called “Evocative Imagery” you can cultivate courage, patience, tolerance, humor, concentration, self-confidence or any other quality you'd like to embody.

3 0
2 years ago
Code is the code or instructions used to create a Web page or<br> program.
Paha777 [63]
Answer:
HTML
Explanation:

5 0
2 years ago
Other questions:
  • How do open online courses help with independent learning? (1 point)
    13·2 answers
  • For wired network cards that get their IP addresses through DHCP, what can be set manually?
    5·1 answer
  • In general, what is the leftmost point of a circle with radius r centered at (x,y)?
    8·1 answer
  • A firewall, when properly implemented, can prevent most attacks on your system.
    11·1 answer
  • Which of the following actions would help people determine their interests?
    11·1 answer
  • Write algorithm to find (a+b)^2=(a+b)*(a+b)​
    9·1 answer
  • Hey yall wanna send me some just ask for my phone #
    13·1 answer
  • Explain logic circuit​
    8·1 answer
  • A bank wants to reject erroneous account numbers to avoid invalid input. Management of the bank was told that there is a method
    8·1 answer
  • Write a java code to print Multiplication Table Till 20
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!