John Curran
/
Lab2_functionsandrecursivefunctions_JohnCurran_T00214119
Lab Question 2 Functions & recursive functions
main.cpp@0:c87e6041f68f, 2021-04-17 (annotated)
- Committer:
- johnc89
- Date:
- Sat Apr 17 12:14:10 2021 +0000
- Revision:
- 0:c87e6041f68f
- Child:
- 1:25616f0791d2
lab 2 part 1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
johnc89 | 0:c87e6041f68f | 1 | |
johnc89 | 0:c87e6041f68f | 2 | // Lab 2: Functions and recursive actions |
johnc89 | 0:c87e6041f68f | 3 | // John Curran T00214119 |
johnc89 | 0:c87e6041f68f | 4 | |
johnc89 | 0:c87e6041f68f | 5 | |
johnc89 | 0:c87e6041f68f | 6 | #include "mbed.h" |
johnc89 | 0:c87e6041f68f | 7 | Serial pc(USBTX,USBRX);// serial communications |
johnc89 | 0:c87e6041f68f | 8 | |
johnc89 | 0:c87e6041f68f | 9 | int j=1, k=0, fib =0; |
johnc89 | 0:c87e6041f68f | 10 | |
johnc89 | 0:c87e6041f68f | 11 | int N = 10 ; |
johnc89 | 0:c87e6041f68f | 12 | |
johnc89 | 0:c87e6041f68f | 13 | int main() { |
johnc89 | 0:c87e6041f68f | 14 | for (int count = 0; count < N; count ++ ) { |
johnc89 | 0:c87e6041f68f | 15 | pc.printf (" %d, ",fib); |
johnc89 | 0:c87e6041f68f | 16 | fib = k+j; |
johnc89 | 0:c87e6041f68f | 17 | k=j; |
johnc89 | 0:c87e6041f68f | 18 | j=fib; |
johnc89 | 0:c87e6041f68f | 19 | } |
johnc89 | 0:c87e6041f68f | 20 | } |