Previous topic | Ada Home Page | Index

If-then example

In the example below, the printing of a message should only happen if a particular condition is satisfied (the user has entered a single-digit number). The choice is whether to take that action or not; there is no alternative action.

This stiuation calls for a basic if-statement.


with TEXT_IO;
use  TEXT_IO;

procedure simple_if is

	package int_io is new TEXT_IO.INTEGER_IO( INTEGER );
	use int_io;

	number : integer;

begin -- of simple_if

	PUT ( "Enter a number ");
	GET ( number );
	IF number <= 9 THEN
		PUT (" It has only one digit ");
	END IF;
	PUT ( "Thanks for using this program ");
end simple_if;


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