forked from CPRF-Session2/Assignment5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment5.txt
More file actions
13 lines (10 loc) · 1.18 KB
/
Assignment5.txt
File metadata and controls
13 lines (10 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
Madeleine Charity
1. What do each of the following mean? Include a description of the syntax or an example.
a. Passing by value:
Passing a variable by value means passing the variable to the function by putting it in the argument to be copied. This means that there are now two variables with the same value, and modifying one will not modify the other. ex (int fxn(int value); value++;)
b. Passing by reference:
Passing by refernce is passing a variable by just referencing it. There is only one copy of the variable, and when it is modified in either function the modifications stay in both. ex an array that is declared in int main and then modified in a function called naturalSum.
2. What is the function of the return statement in C?
The return statment returns or gives a value to where the function was called. This value is what is generated by the function, and can be saved and used after the function runs.
3. What is the purpose of writing functions?
Writing functions allow us to execute the same code without rewriting it. This is more conenient and easy to read. We can write a peice of code under a function, and call it multiple times to run with different variables.