void inc(int n){ n++; }
int x=5; inc(x); // x ?
void inc(int& n){ n++; }
int x=5; inc(x); // x ?
int fact(int n){
if(n==0) return 1;
return n*fact(n-1);
}
Step through the call stack (n=4):
[empty]
Q1. What does pass‑by‑value do?
long long fib_rec(int n){ return n<2? n : fib_rec(n-1)+fib_rec(n-2); }
long long fib_it (int n){ long long a=0,b=1; while(n--){ long long t=a+b; a=b; b=t;} return a; }
(JS simulates timing to contrast exponential vs linear ideas.)
Abstraction: fewer moving parts to break.