/* * Copyright (c) 2026 Rose-Hulman Institute of Technology * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include "practice.h" /* 1. Count adjacent decreases: readings[i] < readings[i-1]. * len >= 0; len 0 or 1 gives 0. Do not change readings. * {8, 5, 5, 2} gives 2. {1, 3} gives 0. */ int countDrops(const int* readings, int len) { // TODO: implement this function. (void)readings; (void)len; return -1; } /* 2. If *value is even, divide it by 2 and return 1. * Otherwise leave it unchanged and return 0. Negative integers and zero work too. * An input value of 14 becomes 7 (return 1); 9 stays 9 (return 0). */ int halveEven(int* value) { // TODO: implement this function. (void)value; return -1; } /* 3. Count '.' and '!' characters in a null-terminated string. * Do not change the string. Empty text gives 0. * "Hi! Wait..." gives 4; "why?" gives 0. */ int countMarks(const char* text) { // TODO: implement this function. (void)text; return -1; } /* 4. If available > 0, decrease available by 1, increase sold by 1, * and return 1. Otherwise change nothing and return 0. * Both fields start nonnegative, and incrementing sold will fit in int. * {3, 2} becomes {2, 3} (return 1); {0, 4} stays {0, 4} (return 0). */ int sellOne(struct stock* item) { // TODO: implement this function. (void)item; return -1; } /* 5. For 1 <= len <= 1000, allocate len integers and fill element i * with start + i. Assume these additions fit in int. * Return NULL if allocation fails; otherwise return the heap array. * The caller owns the result and must free it once. * makeRamp(3, 4) gives {4, 5, 6}; makeRamp(1, -2) gives {-2}. */ int* makeRamp(int len, int start) { // TODO: implement this function. (void)len; (void)start; return NULL; }