mirror of
https://github.com/vishapoberon/oberonbyexample.git
synced 2026-04-05 21:02:25 +00:00
into to IF \& ELSE
This commit is contained in:
parent
bb888c228e
commit
d3bfe2ac3f
2 changed files with 52 additions and 0 deletions
42
ifelse/IfElse.Mod
Normal file
42
ifelse/IfElse.Mod
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
MODULE ifelse;
|
||||
|
||||
|
||||
IMPORT Out;
|
||||
|
||||
VAR n, m : INTEGER;
|
||||
|
||||
|
||||
BEGIN
|
||||
IF 8 MOD 4 = 0
|
||||
THEN
|
||||
Out.String("8 is divisible by 4"); Out.Ln;
|
||||
END;
|
||||
|
||||
n := 7; m := 6;
|
||||
|
||||
IF n * m = 42
|
||||
THEN
|
||||
Out.String("7 times 6 equals 42"); Out.Ln;
|
||||
END;
|
||||
|
||||
IF n # m THEN Out.String("7 does not equal 6"); Out.Ln; END;
|
||||
|
||||
IF ODD(n)
|
||||
THEN
|
||||
Out.String("7 is odd"); Out.Ln;
|
||||
ELSE
|
||||
Out.String("7 is even"); Out.Ln;
|
||||
END;
|
||||
|
||||
n := 9;
|
||||
|
||||
IF n < 0
|
||||
THEN
|
||||
Out.Int(n, 0); Out.String(" is negative"); Out.Ln;
|
||||
ELSIF n < 10
|
||||
THEN
|
||||
Out.Int(n, 0); Out.String(" has 1 digit"); Out.Ln;
|
||||
ELSE
|
||||
Out.Int(n, 0); Out.String(" has multiple digits"); Out.Ln;
|
||||
END;
|
||||
END ifelse.
|
||||
10
ifelse/Makefile
Normal file
10
ifelse/Makefile
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
VOC = /opt/voc/bin/voc
|
||||
|
||||
all:
|
||||
$(VOC) -m IfElse.Mod
|
||||
|
||||
clean:
|
||||
rm *.c
|
||||
rm *.h
|
||||
rm *.o
|
||||
rm *.sym
|
||||
Loading…
Add table
Add a link
Reference in a new issue