Abstract:
C is a very old, lower level, Object Orientated, Programming Language that was designed as a improved alternative to D (Programming Language).
To compile and then execute a C program run:
clang source.c -o program
./programTo generate the code after the preprocesor stage use:
clang source.c -E -o source.eTo generate the intermediate representation use:
clang source.c -emit-llvm -S -o source.llvm To generate the assembly code:
clang source.c -S source.sTo generate machine code:
clang source.c -c -o source.oConcepts in C:
Fibonacci:
Recursively:
int fib(int x, int x1, int x2) {
if (x==0) {
return x2;
} else {
return fib(x-1, x1 + x2, x1);
}
}
int main() {
int fib_6 = fib(6,0,1);
}Iteratively:
int fib(int x) {
int x1 = 0;
int x2 = 1;
while (x>1) {
int xtmp = x1 + x2;
x1 = x2;
x2 = xtmp;
x = x - 1;
}
return x2;
}
int main(){
int fib_6 = fib(6);
}