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
spin [16.1K]
2 years ago
9

When do you use a for loop instead of a while loop? (There may be more than one answer.)

Computers and Technology
1 answer:
statuscvo [17]2 years ago
8 0

Answer:

- You know how many times you want the loop to run.

- When there is a defined start and end.

Explanation:

Required:

When to use for instead of while loop?

First, it should be noted that both for loop and while loop are used for iteration. However, depending on the scenario; there is preference on one to the other.

The basic syntax of for loop is:

for(start;end;condition)\{\}

<em>The condition could either be increment or decrement</em>

The basic syntax of while loop is:

while(condition)\{\}

<em>The condition could be any condition whatsoever</em>

Analyzing the options one after the other.

1. How many times the loop to run.

The for loop is preferred here because of the simplicity of the for loop.

2. & 3. Both the for and while loops are used for code repetition and to perform number calculations

4. Defined start and end.

From the syntax of the for loop

for(start;end;condition)\{\}

<em />

A for loop has a definite start and end in its basic syntax and is more preferable to use instead of a while loop.

<em />

<em />

Hence, 1 & 4 answer the question

You might be interested in
g What field in the IPv4 datagram header can be used to ensure that a packet is forwarded through no more than N routers? When a
ad-work [718]

Answer:

a) Time to live field

b) Destination

c) Yes, they have two ip addresses.

d) 128 bits

e) 32 hexadecimal digits

Explanation:

a) the time to live field (TTL) indicates how long a packet can survive in a network and whether the packet should be discarded. The TTL is filled to limit the number of packets passing through N routers.

b) When a large datagram is fragmented into multiple smaller datagrams, they are reassembled at the destination into a single large datagram before beung passed to the next layer.

c) Yes, each router has a unique IP address that can be used to identify it. Each router has two IP addresses, each assigned to the wide area network interface and the local area network interface.

d) IPv6 addresses are represented by eight our characters hexadecimal numbers. Each hexadecimal number have 16 bits making a total of 128 bits (8 × 16)  

e) IPv6 address has 32 hexadecimal digits with 4 bits/hex digit

4 0
3 years ago
What is the QOS model?
Andre45 [30]

Answer:

Quality Of Service

Explanation:

Technology that manages data traffic to reduce packet loss, latency and jitter on the network. QoS controls and manages network resources by setting priorities for specific types of data on the network.

5 0
3 years ago
Distributed computing is a term that describes the work that autonomous computers can do to achieve a common goal, especially in
Bond [772]

Answer:

To find the solution of Global warming, to find the combination of some drugs and test them, etc.

Explanation:

Distributed computing can be described as when a number of computers connected on the network communicate with each other by passing messages, and these systems are known as distributed systems.

There are various goals that can be accomplished using distributed computing, one of them is to find the solution of Global warming, by coordinating with different areas.  

Another one is to find the combination of some drugs and test them to make new medicine.

7 0
3 years ago
Which of the following processes should Angel use to merge cells A1:D4 to create a title?
podryga [215]

Answer:

Highlight cells A1:D4, right-click and select Format Cells, click Alignment, and choose the Merge cells option.

Explanation:

We merge cells with the help of following methods.

<u>Method 1  </u>

  1. Highlight cells A1:D4
  2. click on the Home tab
  3. click on the <u>Merge and Center</u> icon in the Alignment group

1st method is not given in options of question.

<u>Method 2</u>

  1. Highlight cells A1:D4
  2. right-click and select Format Cells
  3. click Alignment
  4. choose the Merge cells option

<em>2nd method is matching with </em><em><u>option D. </u></em><em>So, Option D is the answer.</em>

<u />

6 0
3 years ago
Write a program that produces the following output (where the user may enter any positive integer under 10):______
Mekhanik [1.2K]

Answer:

// The Scanner class is imported to allow the program receive user input

import java.util.Scanner;

// The class is defined called Solution

public class Solution {

   // The main method is defined which begin program execution

   public static void main(String args[]) {

     // Scanner object 'scan' which receive user input from the keyboard

     Scanner scan = new Scanner(System.in);

     // the userInput variable is initially set to 1 (true) to allow the program continue prompting the user for input

     int userInput = 1;

     // while loop which continue execution as long as the userInput is greater than 0 and less than 10

     while (userInput > 0 && userInput < 10){

         // Prompts is displayed to the user to enter number below 10

         System.out.println("Enter a positive integer under 10:__________");

         // the next input is assigned to userInput

         userInput = scan.nextInt();

     }      

   }

}

Explanation:

The above code continue prompting the user to input an integer as long as the input is greater than 0 and less than 10.

3 0
3 years ago
Other questions:
  • . Gathering information with your eyes is called __________.
    6·1 answer
  • The IP address 129.53.82.20 falls under what class of IP addresses??
    5·2 answers
  • Write two statements to read in values for birthMonth followed by birthYear, separated by a space. Write a statement to print th
    12·1 answer
  • What is a DreamScape?<br> Explain <br> and give example (if you want)
    10·1 answer
  • What is a text designed for editing and authoring code is<br> A code editor <br> B
    9·1 answer
  • Sam has created a fashion website. There are many subscribers to his website. He has added new blogs, pictures, and articles abo
    13·1 answer
  • Which situations are better suited to an indefinite (while) loop? Select 3 options.
    5·2 answers
  • What are the four different orchestral instrument families?
    6·2 answers
  • Please helpppppppppppppppppp please I’m stuck!
    15·1 answer
  • What is operating system​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!