🧩Pass by Value
Also known as Call by Value, Passing by Value
The function gets a copy. Changing the copy leaves the first one alone.
Think of it like
It is like giving a friend a copy of your drawing. They can scribble on it, and yours stays clean.
Example
A score of 5 is passed to a function that adds 1. Inside it is 6, but back outside the score is still 5.
Why it matters
It tells you whether a function can change your data. Guess wrong and a bug hides in a value you thought was safe.
Definition
Example code
cpp
void addOne(int n) { n = n + 1; }
int score = 5;
addOne(score);
// score is still 5