Day 7 Recap Questions
  1. How do you get the number of elements of an integer array?
  2. Is the size of a string array the same as the string length?
  3. What is the difference between a function declaration and a function definition?
  4. Can you have two functions with the same function name in a program?
  5. How does passing an integer array to a function differ from passing a single integer variable into a function?
  6. How can you make an array that is passed into a function not modifiable?
  7. What is the output of the following code segment:
    #include <stdio.h>
    void func(int arr[], int size) {
     for (int i = 0; i < size; i++) 
         arr[i] = arr[i] * 2;
    }
    int main() {
     int numbers[5] = {1, 2, 3, 4, 5};
     func(numbers, 5);
     for (int i = 0; i < 5; i++) {
         printf("%d ", numbers[i]);
     }
     return 0;
    }
    
  8. What is the down-side to recursion?
  9. What happens if your recursive function does not have a base case?
  10. Write both the base case and the recursive case for the function int sum_of_digits(int n) that returns the sum of the digits of n (n>=0).