Warning: Is your home computer a true 32-bit machine
(like falun) or a 16-bit computer?
Do you know how to make your C/C++ compiler support 32-bit
operations?
C Programming
C Control Structures
There are a number of control structures in C, we briefly
list them here:
{ statements }
if ( expression )
statement
if ( expression ) if ( expression ) {
statement statements
else } else {
statement statements
}
while ( expression ) while ( expression )
statement { statements }
do
statement
while ( expression ) ;
The iteration continues when the expression evaluates
to a non-zero value, a zero value ends the iterating.
for ( expression1 ; expression2 ; expression3 )
statement;
All three expressions are optional
expression1;
while ( expression2 ) {
statement
expression3;
}
switch ( expression ) {
case constant : statement
case constant : statement
case constant : statement
.
.
.
default : statement
} ;
The expression in the switch must evaluate to an
integer value, all the case labels (constant) must also have integer
values. When the switch statement is entered the expression is evaluated
and control transfers to the matching case (like a goto statement). If
there is no matching case default is used, the default case is optional.
Control flows from one case to the next, the statement is not automatically
exited when the next case is reached
break ;
The break statement causes the termination of the
smallest enclosing while, do, for or switch
statement A break is commonly used to separate the cases in a switch
statement.
continue ;
Causes control to transfer to the loop continuation (end of the loop) portion of the smallest enclosing while, do or for statement This statement is used to transfer control to the next iteration of the loop, that is, terminate the current iteration and start on the next iteration
In the example we use the following strategy to read from
a file or terminal
read first line
while ( not-at-end ) {
process the line
read next line
}
The main problem with this approach is that we need two
read statements.
An alternative schema (plan) uses the break statement
while ( TRUE ) {
read next line
if ( EOF )
break;
process the line
}