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
The movie polar express was critically acclaimed due to the unbelievably lifelike movements of Tom Hanks character
Fed [463]
I think it is greyhound
6 0
3 years ago
Arrays are commonly used to store data items. Arrays can be managed in ways that fill, iterate over, add to, and delete items fr
vfiekz [6]

Answer:

mark me brainlist

Explanation:

3 0
3 years ago
True / False
Tju [1.3M]

Answer:

TRUE, The PC is always incremented by the same amount in fixed-length instruction set architectures.

Explanation:

Its TRUE that Program Counter ( PC ) is always incremented by the same amount in fixed - length instruction set architectures ( fixed length ISA) . As the instruction set length is fixed in fixed - length instruction set architectures, the Program Counter to fetch the next instruction set it has to be incremented by fixed length. This fixed length depends on the hardware of the architecture (the number of bytes each machine word contains and number of machine words per memory location)

7 0
4 years ago
Which of the following is not a good practice for effective Internet searches? Search for specific keywords that define your top
Bumek [7]

Answer:

Be general in your search query to get as many results possible

3 0
3 years ago
What are the different categories of a computer
Lorico [155]

Answer:Computer is a machine that can be program to manipulate the symbols.

Explanation:There are five different categories of a computer.

(1)super computer (2) mainframe (3) personal computer (4) workstation

(5) minicomputer

(1)super computer: super computer is the term fastest computer available current time.super computers are very expensive and specialized computer.

(2)mainframe : mainframe computer is perform to the execute the program the currently.

(3) personal computer: The most popular use for personal computer playing games and surfing internet.

(4)workstation: This type of computer used for the engineer applications desktop publishing , software development.

(5)minicomputer: The general a minicomputer is multiprocessing system it is a midsize computer.

6 0
3 years ago
Other questions:
  • Data bars describe a graphic element that
    7·1 answer
  • Luentifying message rullidl Upuuns
    12·1 answer
  • How to calculate a pid controller
    8·1 answer
  • Match the limits of the user with an appropriate design response. 1. severe arthritis, unable to type or use a mouse on a reliab
    11·1 answer
  • James gets a job at a multinational corporation. On his first day at work, he finds out that the numerical code assigned by the
    10·1 answer
  • You are almost finished updating a Website. As part of the update, you have converted all pages from HTML 4.0 to HTML5. The proj
    7·1 answer
  • A collection of code makes up which of the following?
    14·2 answers
  • Who would win in a fight, Noble 6 from halo reach or Master Chief??
    6·2 answers
  • Explain how information in an access log could be used to identify the true identity of an impostor who has acquired unauthorize
    13·1 answer
  • Create a timeline of the evolution of computers and their impact on society
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!