well, my professor said that we are not supposed to ask for any inputs to store in the array, everything starts at 0 and goes up from there. I have some code but it gives me 0 all the time as the value for the convolution
Code:
#include<stdio.h>
void mult( int f[], int g[], int n){ //function to multiply first array by 4
int i;
for (i =0; i < n; i++){
g[i] = 4 * f[i]; //multiply f[i] by 4 so the series is sampled every four
}
}
void convo(int f[], int g[], int h[], int n){ /*function to convolve the 2 arrays*/
int i, j;
for(i = 0; i < n; i++){
h[i] = 0;
for(j = 0; j < n; j++){
if (g[j]-f[i]>0){
h[i] += g[j] * f[j-i]; /*convolve the two arrays*/
}
}
printf("index: %d\t convolution %d\n", i, h[i]); //display the index number starting from 0 and its convolution value
}
}
int main()
{
int n = 0;
printf("enter the number of elements in the array: ");
scanf("%d", &n);
int f[1000];
int g[100];
int h[n];
mult(f, g, n); //call mult function
convo(f, g, h, n); //call convo function
return 0;
}