logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/cs256su21code/q3sol.txt

### QUIZ 3 SOLUTIONS ###

1. This method copies the actual value of an argument into the formal parameter of the function.

	Answer: call by value

2. Local variables can be used only by statements that are inside that function or block of code.

	Answer: True

3.  Give me a single line of code that declares an array named "numbers" that can store up to 64 integers

	Answer: int numbers[64];


4. A function that does not return a value has this return type.

	Answer: void

5. Write a function (not a whole program) named "cube" that takes one integer as an argument and returns the cube of that number (also an integer).
   Recall that the cube of a number is the same number multiplied by itself three times.

   Answer 1: 

   int cube(int n){

   	 return n * n * n;
   
   }


   Answer 2: 

   int cube(int n){

   	 int res;
   	 res = n * n * n;
   	 return res;

   }

6. By default, C uses call by reference to pass arguments
	
	Answer: False 

7. The first element of an array is at what index?

	Answer: 0

8. Consider the following array declaration:
    
    int stuff[16];

	Give me a single line of code that assigns the integer value 100 to the very LAST index of the array.

	Answer: stuff[15] = 100;


9. All arrays consist of contiguous memory locations.

	Answer: True