answersLogoWhite

0

Definition and comments for loop

Updated: 12/24/2022
User Avatar

Wiki User

14y ago

Best Answer

The C and C++ for loop is defined as...

for (init-expression; test-expression; loop-expression) loop-statement;

  • The init-expression is executed once.
  • At the top of the loop, test-expression is evaluated. If it is false, control passes to the statement following loop-statement.
  • The loop-statement is executed. It may be one statement, it may be a block of statements, or it may be no statement. If it is no statement, the semi-colon is required.
  • At the bottom of the loop, loop-expression is executed, and then control passes to the test-expression at the top of the loop for another go-around.
  • Each of init-expression, test-expression, and loop-expression may be missing. The semi-colons are required. The formal "forever" loop is for (;;) loop-statement; in which case the only way out is the break statement.
  • Since each of init-expression, test-expression, and loop-expression can have side-effects, sometimes a loop is constructed with no loop-statement, and all processing is done between the parentheses.
  • If test-expression is initially false, loop-expression and loop-statement are never executed. The init-expression is always executed only one time, and test-expression is executed at least one time.
  • At any point during loop-statement, the breakstatement will exit to the statement following loop-statement, and the continue statement will jump to the loop-expression at the bottom of the loop.
User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Definition and comments for loop
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Definition of jump in loop?

It is a jump, which in a loop.


What are its program components?

the main() function,the#include Directive, the variable definition. function prototype, program statements, the function definition,program comments and braces are the components of program in C++


Definition of sentinel-controlled loop?

In a Sentinel-Controlled loop, a special value called a sentinel value is used to change the loop control expression from true to false.For example,when reading data we may indicate the "end of data" by a special value,like -1 and 999.The control variable is called sentinel variable.A sentinel-Controlled loop is often called indefinite repetition loop because the number of repetitions is not known before the loop begins executing.


Definition of a critical instrument loop?

critical instument means i measure,record and accuracy and which donot effect effcet on product quality


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

Related questions

Definition of jump in loop?

It is a jump, which in a loop.


What is the definition and syntax of for next loops?

loop within in a loop is called for next loop


Definition of do loop while in visual basic?

There are 3 type of loop 1 is for loop 2 is loop while 3 is loop untile


What is the definition of open loop process control?

it is when a control loop is open and processing


What is an open loop in control systems?

A: By definition there is no control on a system in an open loop situation. simply . it has no feedback


What is the definition of 'nested' in C programming?

In C a structure within a structure is called nested. For example, you can embed a while loop in another while loop or for loop in a for loop or an if statement in another if statement.


What is the science definition of a depression contour line?

its a closed loop with dashes inside indicates a depression


What is the definition of close the loop in recycling?

The term "close the loop" is a three part process: 1) recycle our waste, 2) make something new out of it, 3) buy recycled.


What is the definition of closed loop communication?

Closed loop communication involves the repetition of information to avoid a misunderstanding or miscommunication. The sender of the information asks the recipient to repeat the information he has just heard and the loop continues until the information is correctly understood.


What are its program components?

the main() function,the#include Directive, the variable definition. function prototype, program statements, the function definition,program comments and braces are the components of program in C++


How long does it really take the earth to travel around the sun?

It really requires an entire year for earth to loop-de-loop the sun. That is what the definition of a year is--the amount of time it takes our orb to orbit once.


Definition of sentinel-controlled loop?

In a Sentinel-Controlled loop, a special value called a sentinel value is used to change the loop control expression from true to false.For example,when reading data we may indicate the "end of data" by a special value,like -1 and 999.The control variable is called sentinel variable.A sentinel-Controlled loop is often called indefinite repetition loop because the number of repetitions is not known before the loop begins executing.