annotate examples/c3/functions.c3 @ 364:c49459768aaa

Work on globals
author Windel Bouwman
date Wed, 19 Mar 2014 20:24:03 +0100
parents 158068af716c
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