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]
4 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]4 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]4 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
How many people employed in the United States work in a job related to digital media?
polet [3.4K]
I feel like more people are employed in the united states more than ever
5 0
3 years ago
When computer boots which I pont program starts first? O Operating System O Metaphor System O Basic System O Computer System​
beks73 [17]
The answer is Operating system
8 0
3 years ago
Explain and give examples of at least two search engines.
ale4655 [162]
Search engines are programs that search for and identify items based on a user input keyword, phrase, etc. Examples include google, bing, etc.
5 0
4 years ago
When a program is being implemented, which step comes after executing
adoni [48]

Answer:

c) maintaining

Explanation:

A software development life cycle (SDLC) can be defined as a strategic process or methodology that defines the key steps or stages for creating and implementing high quality software applications. There are seven (7) main stages in the creation of a software and these are;

1. Planning.

2. Analysis.

3. Design.

4. Development (coding).

5. Testing.

6. Implementation and execution.

7. Maintenance.

Hence, when a program is being implemented, the step which comes after executing is maintaining. This is ultimately the last stage of the software development process and it involves regular updates and other management tasks.

8 0
3 years ago
In 3 sentence explain what is a spreadsheets.
Alex73 [517]

Answer:

A spreadsheet is a computer application for organization, analysis and storage of data in tabular form. Spreadsheets were developed as computerized analogs of paper accounting worksheets. The program operates on data entered in cells of a table.

Hope this helped, have a good day

5 0
3 years ago
Other questions:
  • Which mode of IPSec should you use to assure the integrity and confidentiality of data within the same LAN?a. AH promiscuous mod
    6·1 answer
  • Write a program that produces this output:
    10·1 answer
  • Which part of the water cycle is most affected by a sunny day with few clouds?
    5·2 answers
  • There is only one_________ per network, but there can be many _________connecting internal portions of the network.
    14·1 answer
  • The _____________ RTN describes the overall effectof instructions on the programmer visible registers
    9·1 answer
  • Define foreign key. What is this concept used for?
    6·1 answer
  • Difference between hardcopy and hardware​
    6·1 answer
  • Kelly arrives for work at a restaurant at 5:00 p.m. Once there, she washes and chops vegetables, then sets aside ingredients and
    8·2 answers
  • Write a program that ask a user to input radius of a circle and display circumference of a circle
    13·1 answer
  • What is the value of this expression:<br> ‘there' == 'here'
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!