Why does executing this produce a segmentation fault?
#include <stdio.h>
int populate_array(int sin, int *sin_array) {
    //setting up dummy variables to test whether sin is a 9 digit in
    int dummy = sin;
    int count = 0;
    while (dummy != 0) {
        dummy = dummy / 10;
        count = count + 1;
    }
    if (count != 9) { //10 didn't divide into sin exactly 9 times, thus the number is not a 9 digit int 
        return 1;
    }
    else{
        for (int i = 8; i >= 0; i--) { //sin is a 9 digit int, so populate array
            sin_array[i] = sin % 10;
            sin = sin / 10;
        }
        return 0;
    }
}

int main() {
    int sin_array[9];
    printf("%d/n", check_sin(sin_array));
}

Yes, because the populate_array function is not called.
Will executing main result in a segmentation fault?
#include <stdio.h>
int check_sin(int *sin_array) {
    if (sin_array[0] == 0) { //assignment simplification: if it starts with 0 its invalid
        return 0;
    }
    else {
        int result[9];
        int sum = 0;

        for (int i = 0; i < 9; i++) {
            if (i % 2 == 0) {
                //even indices get multiplied by 1
                result[i] = sin_array[i]; //the result at i is just going to be the digit since i * 1 = i
            }
            else {
                //odd indices get multiplied by 2, and if its a 2 digit number than add the 2 digits and output it to result[i]
                result[i] = ((sin_array[i] * 2) / 10) + ((sin_array[i] * 2) % 10);
                //if the product is < 10, the division is 0 and the modulo will be the digit, so the sum is just the digit
                //if the product is >= 10, the division is the first digit of the product, the modulo is the second, so the sum 
                //are the added digits
            }
        }
        for (int i = 0; i < 9; i++) {
            sum = sum + result[i];
        }
        if (sum % 10 == 0) {
            return 0;
        }
        return 1;
    }
}

int main() {
    int sin_array[9] = {8, 1, 0, 6, 2, 0, 7, 1, 6};
    printf("%d/n", check_sin(sin_array));
}
