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
Which of the following is something all models use to determine relationships?
Aleks [24]

Answer:

Math

Explanation:

Which of the following is something all models use to determine relationships?

The answer would be math.

8 0
4 years ago
Suppose that a database modification results in the execution of a trigger but that trigger generates another modification that
zhenek [66]

Answer:

The database can detect only system-defined events.

Explanation:

A trigger is like a stored procedure that Oracle Database invokes automatically whenever a specified event occurs.trigger is like a stored procedure that Oracle Database invokes automatically whenever a specified event occurs.

Both triggers and constraints can constrain data input, but they differ significantly.

A constraint applies to both existing and new data. For example, if a database column has a NOT NULL constraint, then its existing data is NOT NULL and no DML statement can violate the NOT NULL constraint.

A trigger applies only to new data. For example, a trigger can prevent a DML statement from inserting a NULL value into a database column, but the column might contain NULL values that were inserted into the column before the trigger was defined or while the trigger was disabled

5 0
4 years ago
select three types of school which specifically emphasize learning through creativity, self expression, and play
sattari [20]

The first thing that comes to mind is preschool. Then kindergarden. Another one would probably be a daycare center, but I'm not sure that qualifies as a school.

4 0
4 years ago
Read 2 more answers
Which of the following algorithmic efficiencies would be considered LEAST efficient?
LenaWriter [7]

Answer:exponential

Explanation: I believe

8 0
3 years ago
The maximum-valued element of an integer-valued array can be recursively calculated as follows: If the array has a single elemen
Tasya [4]

Solution :

#include <iostream>

using namespace std;

//Function Declaration

int max(int arr[],int size);

int main()

{

//Declaring variable

int size;

 

while(true)

{

cout<<"Enter the no of elements in the array :";

cin>>size;

if(size<=0)

{

  cout<<"Invalid.Must be greaterthan Zero"<<endl;

  continue;

  }

  else

  break;

  }

 

//Creating an array

int arr[size];

/* getting the inputs entered by

* the user and populate them into array

*/

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

{

cout<<"Enter element#"<<i+1<<":";

cin>>arr[i];

}

//calling function

int maximum=max(arr,size);

//Displaying the output

cout<<"The maximum Element in the Array is :"<<maximum<<endl;

return 0;

}

/* Function implementation which finds

* the maximum element in the array and return it

*/

int max(int arr[],int size)

{

//Declaring the static variables

static int k=0,maximum=-999;

 

/* This if block will execute only if the value of k

* is less than the size of an array

*/

if(k==size-1)

{

   return arr[0];

  }

else if(size-1>k)

{

if(arr[k]>maximum)

maximum=arr[k];

 

//Incrementing the k value

k++;

 

//Calling the function

max(arr,size);

}

return maximum;

}

4 0
3 years ago
Other questions:
  • A raised dot (ú) shows where the enter key was pressed. true or false.
    13·1 answer
  • When backing up a database server to LTO tape drives, the following schedule is used. Backups take one hour to complete.
    12·1 answer
  • Write a function named max that accepts two integer values as arguments and returns the value that is the greater of the two. Fo
    12·1 answer
  • PLEASE HELP!!!!!!!!!!!!!!!!!!!!
    13·1 answer
  • What message do you want to share with a wide audience
    7·1 answer
  • You have just replaced the motherboard in your computer. now your computer will not start. you press the power button on the sys
    6·1 answer
  • How does a Graphical User Interface (GUI) interact with a desktop or laptop computer?
    11·1 answer
  • What is the best way to appeal to an audience in any medium ?
    11·1 answer
  • . Aisha’s supervisor asks her to create an aspect of a program that will hold data and make it easy to access. What does Aisha n
    5·1 answer
  • A ____ risk assessment evaluates threats to and vulnerabilities of the network.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!