my professior gave us an example program for a fiter.. but I can't get it to work...
my professor gave us an example program for a filter.. but I can't get it to work...
This is my 1st time using C++ and before we where learning C... so I can't easily see why it doesn't work.... this is an example and shouldn't have errors but ya.. it does so can anyone help me? thanks
Code:
#include <iostream>
using namespace std;
int main()
{
int i, numpts;
double input[25]; //store values for filtering
cout << "enter number of points: ";
cin >> numpts;
for (int i = 0; i < numpts; i++)
{
cout << "Enter a point: ";
cin >> input[i];
}
double output[25]; //store filtered results
double alpha = .5;// 0 < alpha 1
output[0] = input[0];
for (int i = 1; i < numpts; i++)
output[i] = alpha*input[i]+(1-alpha)*output[i-1];
for (int i = 0; i < numpts; i++)
{
cout << "Output " <<i << " is " << output[i];
cout << "\n";
}
return 0;
}