int *curr_val; int history[5]; curr_val = history; // point to the first element of history // to get a new element: *curr_val++ = get_new_value(); // make sure to wrap at the end of the history array // alternatively, replace the pointer with an index value and access the array through that if(curr_val > &history + 5) curr_val = history; // for getting the average sum up all values in the array history int avg; avg = 0; for(int i = 0; i < 5; i++) avg += history[i]; avg /= 5; // now avg has the average of the last 5 elements, including the value we gathered at the start of this snippet get_new_value = whatever I want to add, such as data or w/e right? followed by a ()