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]
3 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]3 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
What is the current record holder for the fastest car in the world? What is the top speed of it? 100 points to whoever gets it c
olchik [2.2K]
It’s 257 mph

Hope this helps !!!!!
7 0
3 years ago
Read 2 more answers
HELP!!!<br> THIS HAPPENS EVERY TIME
Lelu [443]
Idek but hope u figure it out!
4 0
3 years ago
Read 2 more answers
When you write a check, why do you always begin writing the amount of the check as far to the left as you can?
Ivenika [448]

Answer:

You start at the left without leaving any paces so no one can add any more numbers.

Explanation:

5 0
3 years ago
Which of the following is a Reach Key on your keyboard?
zhannawk [14.2K]

Answer:J key

Explanation:I want my brainlyiest pls

6 0
2 years ago
Which of the following statements is true?
jeka57 [31]

Answer: Constructors can specify parameters but not return types.

Explanation:

public class Student {

 int roll_no;

 public Student(int a) {

   roll_no = a;

 }

public static void main(String[] args) {

   Student abs = new Student(10);

   System.out.println(abc.roll_no);

 }

}

In the above code we have illustrated the working of constructors. We have a class with the name Student. then a constructor is created of the class called as the class constructor. In the main we create an object of the class and with this object we invoke the constructor and also pass a parameter. Here in the code we are passing the roll no of the student.

So we can say that constructor is called during the runtime when the object created invokes the constructor so a constructor can have many arguments but it does not have a return type.

7 0
3 years ago
Other questions:
  • In older systems, often the user interface mainly consisted of ____-control screens that allowed a user to send commands to the
    11·1 answer
  • Why has unicode become the standard way of converting binary to text??
    8·1 answer
  • To edit the text in a smartart graphic, what must be done first ?
    7·2 answers
  • Sandy's keyboard is not inputting data into her computer which key should she press to verify it is connected to her computer...
    11·1 answer
  • Several students are making presentations for a science class. The chart describes the concept that each student will present to
    10·1 answer
  • What is copy and paste?
    13·2 answers
  • 12. In cell A14, use the INDEX function and structured references to display the value in the first row and first column of the
    8·1 answer
  • 3.1.1 What type of goods are car radio and remote control.​
    12·1 answer
  • The average numbers of shares a piece of content receives is known as its:
    7·1 answer
  • 3.5 lesson practice quiz Edhesive
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!