You are on page 1of 4

ASSIGMENT C++

Bjarne Stroustrup
1.Go to
The goto statement unconditionally transfers control to the statement labeled by the
specified identifier.

2 .While
The test of expression takes place before each execution of the loop; therefore,
a while loop executes zero or more times. expression must be of an integral type, a
pointer type, or a class type with an unambiguous conversion to an integral or pointer
type.
A while loop can also terminate when a break, goto, or return within the statement body
is executed. Use continue to terminate the current iteration without exiting
the while loop. continue passes control to the next iteration of thewhile loop.

3 .Break and Continue


Break
Although you have already seen the break statement in the context of switch
statements, it deserves a fuller treatment since it can be used with other types of loops
as well. The break statement causes a do, for, switch, or while statement to terminate.
This includes the for each loops included in C++11.
Breaking a switch
In the context of a switch statement, a break is typically used at the end of each case to
signify the case is finished
Continue.
Forces transfer of control to the controlling expression of the smallest enclosing do, for,
or while loop.

4.While True
I have seen this sort of thing used a lot, but I think it is rather strange... Wouldn't it be
much clearer to say while(true), or something along those lines?
I'm guessing that (as is the reason for many-a-programmer to resort to cryptic code) this
is a tiny margin faster?
Why, and is it really worth it? If so, why not just define it this way

5.Do/ While

The test of the termination condition is made after each execution of the loop; therefore,
a do-while loop executes one or more times, depending on the value of the termination
expression. The do-while statement can also terminate when a break, goto,
or return statement is executed within the statement body.
The expression must have arithmetic or pointer type. Execution proceeds as follows:
1. The statement body is executed.

2. Next, expression is evaluated. If expression is false, the do-while statement


terminates and control passes to the next statement in the program.
If expression is true (nonzero), the process is repeated, beginning with step 1.

6.Jump / Loop

A C++ jump statement performs an immediate local transfer of control.

Loop

Execute a sequence of statements multiple times and abbreviates the code that
manages the loop variable.

7.if / else

If

If the boolean expression evaluates to true, then the if block of code will be
executed, otherwise else block of code will be executed.

Else

The else clause of an if...else statement is associated with the closest


previous if statement in the same scope that does not have a
corresponding elsestatement.

You might also like