C++ Assing
C++ Assing
notable for the creation and development of the widely used C++ programming language.He is a
Distinguished Research Professor and holds the College of Engineering Chair in Computer
Science at Texas A&M University, is a visiting professor at Columbia University, and works
at Morgan Stanley as a Managing Director in New York.
4.
5.
6.
7.
a. Go to
The Go to statement unconditionally transfers control to the statement labeled by the
specified identifier.
The labeled statement designated by identifier must be in the current function.
All identifier names are members of an internal namespace and therefore do not interfere
with other identifiers.
A statement label is meaningful only to a Go to statement; otherwise, statement labels
are ignored. Labels cannot be redeclared.
Continue
Forces transfer of control to the controlling expression of the smallest enclosing do, for,
or while loop.Any remaining statements in the current iteration are not executed. The next
iteration of the loop is determined as follows:
In a do or while loop, the next iteration starts by reevaluating the controlling expression
of the do or while statement.
In a for loop (using the syntax for(init-expr; cond-expr; loop-expr)), the loop-expr clause is
executed. Then the cond-expr clause is reevaluated and, depending on the result, the loop
either ends or another iteration occurs
e. Do / While
Executes a statement repeatedly until the specified termination condition (the expression)
evaluates to zero.
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.
1.The expression must have arithmetic or pointer type. Execution proceeds as follows: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.
EXAMPLE : // do_while_statement.cpp
#include <stdio.h>
int main()
{
int i = 0;
do
{
printf_s("\n%d",i++);
} while (i < 3);
}
f.
Jump / Loop
Jump Statement performs an immediate local transfer of control
Example : Syntax return [expression];
Loop statement repeatedly excutes a target statement as long as a given condition is
true
Example : Syntax while(condition)
{
Statement(s);
}
g. If / Else
Controls conditional branching.
If the value of expression is nonzero, statement1 is executed. If the optional else is
present, statement2 is executed if the value of expression is zero.expression must be of
arithmetic or pointer type, or it must be of a class type that defines an unambiguous
conversion to an arithmetic or pointer type.
In both forms of the if statement, expression, which can have any value except a structure,
is evaluated, including all side effects. Control passes from the if statement to the next
statement in the program unless one of the statements contains a break, continue,
or goto.
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
correspondingelse statement.
For this sample to be unambiguous about if...else pairing, uncomment the braces.
EXAMPLE :
if ( expression )
statement1
[else
statement2]