Previous topic | Next topic | Ada Home Page | Index

Control statements

Decisions

IF statement for two-way decisions

Pseudocode

if (assets > 30000) or (income > 20000) then {
		approved := YES
} else {
		approved := NO
}

Ada statement

if (assets > 30000) or (income > 20000) then approved := YES; else approved := NO; end if;


Loops

WHILE statement for repetition:

  1. evaluate stopping condition
  2. if not met, execute statements in loop body
  3. go back to 1.

Pseudocode

counter := 1;
while (counter <= 100) {
	put (counter)
	counter := counter + 1
}

Ada statement

counter := 1;
while (counter <= 100) loop
	put (counter);
	counter := counter + 1;
end loop;

An example program demonstrates the use of a while loop.


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