November 2011
Beginner
258 pages
5h 1m
English
| Tip 6 | Be Stylish |
![]() | [White Belt] Writing code with good style helps well before the professional world. |
These two functions do exactly the same thing:
| Fibonacci.c | |
| | uint64_t |
| | fibonacci(unsigned int n) |
| | { |
| | if (n == 0 || n == 1) { |
| | return n; |
| | } |
| | else { |
| | uint64_t previous = 0; |
| | uint64_t current = 1; |
| | |
| | while (--n > 0) { |
| | uint64_t sum = previous + current; |
| | previous = current; |
| | current = sum; |
| | } |
| | |
| | return current; |
| | } |
| | } |
| Fibonacci.c | |
| | unsigned long long fbncci(unsigned int quux) { if |
| | (quux == 0 || quux == 1) { return quux; } else { |
| | unsigned long long foo = 0; unsigned long long bar |
| | = 1; while (--quux ... |
Read now
Unlock full access