Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define N 10
- float smoother(float inputTemp);
- int main()
- {
- float result;
- result = smoother(3);
- printf("%f\n", result);
- result = 0;
- result = smoother(2);
- printf("%f\n", result);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = smoother(2);
- result = 0;
- result = smoother(8);
- printf("%f\n", result);
- return 0;
- }
- float smoother(float inputTemp) {
- int i;
- static float input[N];
- float sum = 0;
- float avg = 0;
- for (i=8; i>=0; i--){
- input[i+1] = input[i];
- }
- input[0] = inputTemp;
- for (i=0; i<10; i++){
- sum = sum + input[i];
- }
- avg = sum / N;
- return(avg);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement