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
never [62]
4 years ago
11

The counter variable in the code below increments by 1 each time through the loop. What will the value of counter be after the f

ollowing loop executes?
var counter = 0;
var n = 6;
while(n > 0){
n = n - 2;
counter = counter + 1;
}
console.log(counter)
4

A. 0
B. 1
C. 2
D. 3
E. 4
Computers and Technology
1 answer:
Novosadov [1.4K]4 years ago
8 0

Answer:

The Value of the variable counter will be 3

Explanation:

The code snipped given in the question will execute only three times.

The value of counter will be increased by 1 afer each execution with the initial value of counter set to 0

The condition while n>0 will hold true at the first iteration when n=6. (counter will be increased to 1) and n is reduced by 2 (new value of n =4).

The condition while n>0 will hold true at the second iteration when n=4-2 =2. (counter will be increased to 2) and n is reduced by 2 (new value of n =2).

The condition while n>0 will hold true at the third iteration when n=2-2. (counter will be increased to 3) and n is reduced by 2 (new value of n =0).

At the fourth iteration, the condition becomes false as the value of n is now zero and 0 is not greater than 0. So the the condition becomes false with the value of counter = 3

You might be interested in
A network using multiple cell towers falls under which type of network?
erastova [34]

Answer:

man

Explanation:

multiple area network

8 0
4 years ago
Question 9
Irina18 [472]

Answer:

Outsourcing

Explanation:

The boom in collaboration between U.S. companies and workforces in India created a need for Outsourcing.

I believe this is correct, but I'm not 100% certain.

8 0
2 years ago
To locate all the documents in a Mongo database that match an expression, use the _____________ method.
Lena [83]

Answer:

find()

Explanation:

When dealing with MongoDB the method that needs to be used in this scenario would be the find() method. This method basically returns all of the records that exist in the collection on which it is called, if no parameter is passed. If you pass a parameter/expression then only the records that match completely the expression will be returned to the user, otherwise nothing is returned. For example, on a database (db) we would call the following

db.find() ... This will return all records

db.find({specific}) ... This will return only the records that match specific.

4 0
3 years ago
Is a component that provides a button control in a gui application or applet?
harina [27]
<span>GUI is a graphical user interface. It is a graphical window that provides interaction with the user. 
</span>The button is a pushbutton, which can be pressed to trigger an action.<span>
A graphic control component or a control element is a component that provides a button control in a GUI application. It is also called a control element because it </span><span>is an element of interaction between the user controlling the application.</span>
7 0
4 years ago
¿por qué se debe seleccionar todo el texto de un documento de word?. ​
DedPeter [7]

Explanation:

La selección de texto también se conoce como resaltar texto. Se usa a menudo cuando se usa Microsoft Word para tareas como formatear, eliminar, mover o copiar texto



4 0
3 years ago
Other questions:
  • Which osi reference model layer is responsible for transmitting information on computers connected to the same local area networ
    6·1 answer
  • Consider that an individual threat agent, like a hacker, can be a factor in more than one threat category. If a hacker breaks in
    5·1 answer
  • Given the following code: PreparedStatement ps = connection.prepareStatement("select firstName, mi, lastName from Student where
    13·1 answer
  • Write two examples of hard copy output?​
    9·1 answer
  • on the road you are traveling,the pavement markings change from broken white lines to solid white lines between the lanes of tra
    5·1 answer
  • Someone pls help me with this question (Java)
    5·2 answers
  • List four things that must be taken into consideration when evaluating different resources of information (and explain ANY ONE f
    8·1 answer
  • I don’t understand this, i need help
    7·1 answer
  • Computer science is a blank process
    6·2 answers
  • 1.1 give five (5) reasons why modeling is an important part of system analysis and design
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!