C Programming Examples.
- Swap function: difference between pass by value and pass by reference.
- Fibonacci series. Two implementation: for loop and recursive.
- loop:
int fibo_loop (int n) {
int j = 1;
int k = 1;
int sum;
for (int i = 2; i < n; i++) {
sum = j + k;
j = k;
k = sum;
}
return sum;
}
- recursive:
int fibo_recur (int n) {
if (n<=2) {
return 1;
} else {
return fibo_recur (n-1) + fibo_recur (n-2);
}
}
- The usage of constant, constant functions
- Detect sequence pattern in FSM
- What is the purpose of "volatile" flag in C programming language?
No comments:
Post a Comment