-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.txt
More file actions
81 lines (69 loc) 路 1.68 KB
/
Copy pathtest.txt
File metadata and controls
81 lines (69 loc) 路 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
MainPrgm L3_software ;
Var
< !- Declaration of variables and constants - !>
let x, y, z, i : Int ;
let a, b : Float ;
let matrix : [Int; 10] ;
let array1 : [Float; 10] ;
let array2 : [Float; 10] ;
@define Const MAX_SIZE : Int = 100 ;
@define Const PI : Float = 3.14159 ;
BeginPg
{
{-- This is a comprehensive program
testing all valid MiniSoft features --}
< !- Variable assignments - !>
x := 10 ;
y := 20 ;
z := x + y ;
a := 15.5 ;
b := a * 2.0 ;
a := a + b ;
< !- Array assignments - !>
array1[0] := 5 ;
array1[1] := 10 ;
matrix[15] := 3 ;
< !- Conditional statement - !>
if (x > y) then {
z := x ;
} else {
z := y ;
}
< !- Do while - !>
x := 0 ;
do {
x := x + 1 ;
array1[x] := x * 2 ;
} while (x < 5) ;
< !- For loop - !>
for i from 0 to 9 step 1 {
array1[i] := i * i ;
}
< !- Complex expressions - !>
z := (x + y) * 2 / (MAX_SIZE - 90) ;
< !- Logical operations - !>
if ((x > 5) AND (y < 30)) then {
output("Both conditions are true") ;
}
if ((x > 50) OR (y > 10)) then {
output("At least one condition is true") ;
}
if (!(x == y)) then {
output("x is not equal to y") ;
}
< !- Input/Output operations - !>
output("Enter a value:") ;
input(x) ;
output("You entered:", x) ;
< !- Nested conditions - !>
if (x > 0) then {
if (x > 10) then {
output("x is greater than 10") ;
} else {
output("x is between 1 and 10") ;
}
} else {
output("x is negative or zero") ;
}
}
EndPg ;