/*
* Simple main() that exercises coding problems from CS330 exam 1.
* 2020-03-01 add demo of "leaf()".  Oops.
* 2020-02-26
*/
#include<stdio.h>
#include<stdlib.h>  // atoi()

long int fibolist(long int *lst, int n);
long int leaf(long int *lst, int len);
long int looper(long int *array, long int length);

int main(int argc, char **argv)
{
    int len = (argc > 1) ? atoi(argv[1]) : 5;
    printf("array length: %d\n", len);

    // Demo question 7:
    long int fiboseq[len];
    // starting values for Fibonacci series:
    fiboseq[0] = 1;
    fiboseq[1] = 1;

    for (int i = 0; i < len; i++) {
        long int fibo;
        fibo = fibolist(fiboseq, i);
        printf("fibolist(fiboseq, %d): %ld\n", i, fibo);
    }
    for (int i = 0; i < len; i++)
        printf("fiboseq[%d]: %ld\n", i, fiboseq[i]);

    // Demo question 8:
    long int leafresult = leaf(fiboseq, len);
    printf("leaf(fiboseq, %d): %ld\n", len, leafresult);

    // Demo question 9:
    long int looperans = looper(fiboseq, (long int)len);
    printf("looper(fiboseq, %d): %ld\n", len, looperans);

    return 0;
}