Description |
The Odd function returns true if the given Number is odd (remainder of 1 when divided by 2).
|
|
Related commands |
Boolean |
|
Allows just True and False values |
|
|
|
Example code : Show all odd numbers in the range 1 to 9 |
// Full Unit code. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses // The System unit does not need to be defined Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var
i : Integer;
begin // Display all odd numbers in the range 1 to 9
for i := 1 to 9 do
if Odd(i) then ShowMessageFmt('%d is odd',[i]);
end; end.
|
Hide full unit code |
1 is odd
3 is odd
5 is odd
7 is odd
9 is odd
|
|