if expression1 then begin if expression2 then statement1 else statement2 end 

You are further cautioned that a carelessly formulated if statement can be very costly. Take the example where there are n mutually exclusive conditions, C1 ... Cn, each instigating a distinct action, Si. Let P (Ci) be the probability of Ci being true, and say that P (Ci) >= P (C j) for i < j. Then the most efficient sequence of if clauses is: 

if C1 then Sl else if C2 then S2 else else if C(n-1) then S(n-1) else Sn 

The fulfillment of a condition and the execution of its statement completes the if statement, thereby bypassing the remaining tests. 

If Found is a variable of type Boolean, another frequent abuse of the if statement can be illustrated by: 

A much simpler statement is: 

if Key = ValueSought then Found .- true else Found := false 

Found := Key = ValueSought 

The following program transforms Arabic numbers to Roman numerals by successively reducing the number in a sieve implemented by using if statements. 

program ArabicToRoman(Output); { Program 4.9 - Write a table of powers of 2 in Arabic numbers and Roman numerals. var Rem {remainder}, Number: Integer; 

