The B Programming Language 

 

Handling of Sequence Control  

Mathematical Operators and Precedence
B provides operators for addition, subtraction, multiplication, division, and exponentiation. Binary and unary operators have the same precedence. Using parenthesis can change operator precedence.

Logical Operators
B provides logical operators for not, and, and or. The precedence is (), not, and, and or. 

Relational Operators
The relational operators < (less than), <= (less than or equal to), > (greater than), and >= (greater than or equal to) take integer rvalue operands. The result is 1 if the operands are in the given relation to one another, and O otherwise.                                                                                        

Labels and Goto Statement
The goto statement is as follows:

goto rvalue ;

The rvalue is expected to be of type label. Control is then passed to the corresponding label. Transfers into and out of compound statements are legal, but use of labels as dummy arguments to transfer between functions or function invocations is almost certain to cause disaster.

Statements
Statements define program execution. Each statement is executed in sequence. There are, of course, statements to conditionally or unconditionally alter normal sequencing.
Most statements end with a semicolon
;.

Compound Statement
A sequence of statements in {} braces is syntactically a single statement. This mechanism is provided so that where a single statement is expected, any number of statements can be placed.        

Conditional Statement
A conditional statement has the general form:

if ( rvalue ) statement1 else statement2 ;

This evaluates rvalue and executes statement1 if the rvalue is non-zero, and statement2 if the rvalue is zero.

The "else" clause is optional; thus:

if ( rvalue ) statement

executes statement if the rvalue is nonzero, and skips it if the rvalue is zero.

Break Statement
The break statement has the syntax:

break ;

It is used to break out of a compound statement controlled by a while statement; other compound statements are ignored by it.

Return Statement
The return statement is used in a function to return control to the caller of the function. The first form simply returns control.

return ;

The second form returns an rvalue for the execution of the function.

return ( rvalue ) ;

The caller of the function need not use the returned rvalue.
A return statement is automatically generated before the closing } of a function definition.