🧠 Learning Objectives

By the end of this class, students will be able to:

Passing Arrays to Functions



🔸 Example: Sum of Elements Function

#include <stdio.h>

int sum(int arr[], int n) {
    int s = 0;
    for (int i = 0; i < n; i++)
        s += arr[i];
    return s;
}

int main() {
    int nums[] = {5, 10, 15, 20};
    int result = sum(nums, 4);
    printf("Sum = %d\\n", result);
    return 0;
}

🧠 Explanation:


🛠️ Array Practice


Task 1: Fill array with first 10 multiples of 3

#include <stdio.h>
int main() {
    int arr[10];
    for (int i = 0; i < 10; i++)
        arr[i] = (i + 1) * 3;

    for (int i = 0; i < 10; i++)
        printf("%d ", arr[i]);
    return 0;
}

🧠 Explanation: