answersLogoWhite

0


Best Answer

A For loop requires 3 parameters:

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

{

}

So, the first parameter - int i = 0 - shows the integer that you will be using to cycle with. This variable sometimes corresponds with what you're cycling through, so if you're using an array, array notation dictates that you can access the array with integers.

The second parameter - i < 10 - says that if the i variable is less than 10, do the for loop.

The third parameter - ++i - shows by how many you want to increment or decrement the variable by. This means that the for loop I have provided will run 10 times. (Remember: if you start at 0 - which all arrays and vectors e.t.c will do - you need to start your For loop at 0)

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

That really depends on the programming language, but typical statements include to start a loop include for, while, repeat. Within the loop itself, additional statements may be used to go back to the start of the loop, or to breakout.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Which statements are nedded to control loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are control structures used in javascript?

The control structures used in java script are if-statement, for-loop, for-in loop, while loop,do-while loop, switch-statement, with-statement. try-catch-finally statements.


What are the statements executed within a loop collectively known as?

The body of the loop.


Definition of loop and its types and programs in c plus plus?

Executing a segment of a program repeatedly by introducing a counter and later testing it using the if statement.A sequence of statements are executed until some conditions for termination of the loop are satisfied.A Program loop consists of two segments:1.Body of the loop2. Control StatementDepending on the position of the control statement in the loop, a control strcture may be classifies either as the 2:Entry Controlled LoopExit Controlled Loop1.Entry Control Loop-(Pre Test Loop)The control conditions are tested before the start of the loop execution.If the conditions are not satisfied , then the body of the loop will not be executed.]eg:While Loop2.Exit Control Loop-(Post Test loop)The Test is performed at the end of the body of the loop and there fore the body is executed unconditionally for the first time.eg:Do-Whilewhile loopfor loopdo-while loop


Does The statements within a while loop execute at least once?

No. If the loop condition is not satisfied then the loop would not be executed even once. while(condition) { ..... /statements ..... } here,when the condition is true then the statements will be executed. Otherwise they would be skipped without being executed. Only for do.. while loops this execution at least once holds good.


Why are the statements in the body of a loop called conditionally executed statements?

These statements are called conditionally executed statements because the may or may not be executed. They will be executed while the boolean (true/false) statement in the beginning of the loop is true, but will not be executed when statement is false.

Related questions

What are control structures used in javascript?

The control structures used in java script are if-statement, for-loop, for-in loop, while loop,do-while loop, switch-statement, with-statement. try-catch-finally statements.


Explain control instructions in c plus plus?

Control instructions are instructions that alter the flow of execution. In C++ this include if, if-else statements, switch-case statements and the conditional ternary operator (?:), as well as loop structures (for, while, do-while) and procedural goto statements.


What are the statements executed within a loop collectively known as?

The body of the loop.


How do you calculate loop length?

the multiplication of the number of iterations with the number of statements in that loop is equal to loop length.


Definition of loop and its types and programs in c plus plus?

Executing a segment of a program repeatedly by introducing a counter and later testing it using the if statement.A sequence of statements are executed until some conditions for termination of the loop are satisfied.A Program loop consists of two segments:1.Body of the loop2. Control StatementDepending on the position of the control statement in the loop, a control strcture may be classifies either as the 2:Entry Controlled LoopExit Controlled Loop1.Entry Control Loop-(Pre Test Loop)The control conditions are tested before the start of the loop execution.If the conditions are not satisfied , then the body of the loop will not be executed.]eg:While Loop2.Exit Control Loop-(Post Test loop)The Test is performed at the end of the body of the loop and there fore the body is executed unconditionally for the first time.eg:Do-Whilewhile loopfor loopdo-while loop


Does The statements within a while loop execute at least once?

No. If the loop condition is not satisfied then the loop would not be executed even once. while(condition) { ..... /statements ..... } here,when the condition is true then the statements will be executed. Otherwise they would be skipped without being executed. Only for do.. while loops this execution at least once holds good.


Why are the statements in the body of a loop called conditionally executed statements?

These statements are called conditionally executed statements because the may or may not be executed. They will be executed while the boolean (true/false) statement in the beginning of the loop is true, but will not be executed when statement is false.


How do you use a C-continue statement in a block- without any looping or conditional statements?

In the C language, the continue statement can only be used within a loop (for, while, or do). Upon execution, control transfers to the beginning of the loop.


What type of loop use a Boolean expression to control the number of times that it repeats a statement set of statements?

A counted loop. Typically we use a for loop for counted loops: // loop 10 times... for (int i=0; i&lt;10; ++i) { // ... } We can also use while and do-while loops to do the same thing, however a for loop provides all the information up front where it belongs and we can localise the control variable. With while and do-while loops, the control variable must be declared outside the loop, and the increment is usually specified at the end of the loop. This makes while and do-while loops harder to read because the information that controls the loop is separated: // loop 10 times... int i = 0; while (i&lt;10) { // ... ++i; } A do-while loop is similar to a while loop, but the control expression is placed at the end of the loop thus the loop always executes at least once. This also upsets the logic of a counted loop because the control variable is off-by-one. // loop 10 times... int i = 0; do { // ... ++i; } while (i&lt;11);


When would you use a count controlled loop vs. a flag controlled loop?

Counter Loop:Counter loop is a loop which executes statement up to a fixed number of time.In GW FOR ... NEXT loop is used as counter loop.Controlled Loop:Controlled loop is used to extend the statements till a specific condition is satisfied. In GW WHILE ... WEND is used as controlled loop.


What is difference between entry controlled and exit controlled loops?

An entry control loop places the conditional expression that terminates the loop at the start of the loop, where it is evaluated before each iteration of the loop. If the expression initially evaluates false, then the loop does not iterate at all and control passes to the next statement following the loop. An exit control loop places the conditional expression at the end of the loop, where it is evaluated after each iteration of the loop. This means that the loop always iterates at least once. Generally, exit control loops are best avoided as conditional expressions are ideally placed up front where they can be seen. This helps make code easier to read and thus easier to maintain. However, there will inevitably be cases where an exit control loop helps to express the logic more clearly. In C there are 3 ways to define a structured iterative loop, using the for, while and do-while statements. Although for and while loops are entry control loops and do-while is an exit control loop, conditional expressions may also be placed anywhere in the body of the loop itself, thus it is possible for a loop to be both entry control and exit control. However, to aid readability and maintainability, it is best to place the conditional expression up front whenever possible.


What is the definition of open loop process control?

it is when a control loop is open and processing