#include #include struct steps { int number; char direction; }; // Return the total of steps in the given direction int step_count(char dir, int size, struct steps array[]) { //TODO int i = 0; int count = 0; while (i < size) { if (array[i].direction == dir) { count = count + array[i].number; } i++; } return count; } // This is a simple main function which could be used // to test your step_count function. // It will not be marked. // Only your step_count function will be marked. #define TEST_ARRAY_SIZE 5 int main(void) { struct steps test_array[TEST_ARRAY_SIZE] = { { .number = 3, .direction = 'l'}, { .number = 5, .direction = 'l'}, { .number = 2, .direction = 'l'}, { .number = 13, .direction = 'd'}, { .number = 30, .direction = 'l'} }; printf("%d\n", step_count('l', TEST_ARRAY_SIZE, test_array)); return 0; }