aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/test/in
diff options
context:
space:
mode:
Diffstat (limited to 'c_compiler/test/in')
-rw-r--r--c_compiler/test/in/fib.c20
-rw-r--r--c_compiler/test/in/fib_recusive.c24
-rw-r--r--c_compiler/test/in/for.c5
3 files changed, 46 insertions, 3 deletions
diff --git a/c_compiler/test/in/fib.c b/c_compiler/test/in/fib.c
new file mode 100644
index 0000000..17a3b41
--- /dev/null
+++ b/c_compiler/test/in/fib.c
@@ -0,0 +1,20 @@
+int main()
+{
+ int n, first = 0, second = 1, next, c;
+
+ n = 10;
+
+ for ( c = 0 ; c < n ; c++ )
+ {
+ if ( c <= 1 )
+ next = c;
+ else
+ {
+ next = first + second;
+ first = second;
+ second = next;
+ }
+ }
+
+ return next;
+}
diff --git a/c_compiler/test/in/fib_recusive.c b/c_compiler/test/in/fib_recusive.c
new file mode 100644
index 0000000..55abe06
--- /dev/null
+++ b/c_compiler/test/in/fib_recusive.c
@@ -0,0 +1,24 @@
+int Fibonacci(int n)
+{
+ if ( n == 0 )
+ return 0;
+ else if ( n == 1 )
+ return 1;
+ else
+ return ( Fibonacci(n-1) + Fibonacci(n-2) );
+}
+
+int main()
+{
+ int n, i = 0, c, res = 0;
+
+ n = 10;
+
+ for ( c = 1 ; c <= n ; c++ )
+ {
+ res = Fibonacci(i);
+ i++;
+ }
+
+ return res;
+}
diff --git a/c_compiler/test/in/for.c b/c_compiler/test/in/for.c
index 5163ba5..1f6d104 100644
--- a/c_compiler/test/in/for.c
+++ b/c_compiler/test/in/for.c
@@ -3,11 +3,10 @@ int main()
int x, y, z;
y = 0;
- for(x = 0; x < 50; x = x+1) {
+ for(x = 0; x < 50; x++) {
y = y + 1;
}
- z = y + x - 5;
-
+ z = y + x - 6;
return z;
}