Solution
We use three float arrays: one to store the values of g and two for computing and storing the values of h1 and h2. We define these arrays to be of size 300; thus, our program can accommodate a function g of up to 300 values, and we can compute up to 300 terms of the Fourier series. We cannot first read the number of values of g and then define our arrays to be of that size, because C requires the size of the array to be specified as a constant. After reading the values of g, we use nested for loops to compute the Fourier coefficients and then another for loop to print the amplitude spectrum.