Previous topic | Next topic | Ada Home Page | Index

Truth tables

If statements can be combined in several ways.

To check the final result, to make sure that conditions and actions are correctly associated, we can use a truth table

Multiple alternative if

	if test_1 then
		statement(s)_1;
	elsif test_2 then
		statement(s)_2;
	elsif test_3 then
		statement(s)_3;
	else
		statement(s)_4;
	end if;

test_1 test_2 test_3 s_1 s_2 s_3 s_4
FFF    *
FFT   * 
FTF  *  
FTT  *  
TFF *   
TFT *   
TTF *   
TTT *   

Nested if statements


	if test_1 then
		if test_2 then
			statement(s)_1;
		else
			statement(s)_2;
		end if;
	else
		if test_3 then
			statement(s)_3;
		else
			statement(s)_4;
		end if;
	end if;

test_1 test_2 test_3 s_1 s_2 s_3 s_4
FFF    *
FFT   * 
FTF    *
FTT   * 
TFF  *  
TFT  *  
TTF *   
TTT *   


Previous topic | Next topic | Ada Home Page | Index
c-lokan@adfa.oz.au / 13 Feb 96