annotate test/c3examples/functions.c3 @ 286:d9df72971cbf

Changed package to module
author Windel Bouwman
date Fri, 15 Nov 2013 13:52:32 +0100
parents 05184b95fa16
children
rev   line source
251
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
1
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
2 /*
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
3 Demo of function usage
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
4 */
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
5
286
d9df72971cbf Changed package to module
Windel Bouwman
parents: 284
diff changeset
6 module functiondemo;
251
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
7
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
8 function void main()
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
9 {
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
10 var int a, b, c;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
11 a = 3;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
12 b = a;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
13 a =3;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
14 b = fib(a + 9);
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
15 sum(a, b);
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
16 }
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
17
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
18 function int fib(int x)
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
19 {
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
20 return fib(x - 1) * x;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
21 }
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
22
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
23 function int sum(int a, int b)
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
24 {
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
25 return a + b;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
26 }
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
27