0

Hi,

I have written a small program to calculate Fourier coefficients of square wave.

```
#include<iostream.h>
#include<stdlib.h>
int main()
{
int *A,*B,a,n,i,;
float pi=3.14;
cout<<"Enter value of amplitude";
cin>>a;
cout<<"Enter which harmonic you want to display";
cin>>n;
A=new int[n+1];
B=new int[n+1];
A[0]=0;
for(i=0;i<=n;i++)
{
B[i]=0;
}
for(i=2;i<=n;i=i+2)
{
A[i]=0;
}
for(i=1;i<=n;i=i+4)
{
A[i]=(4*a)/(i*pi);
A[i+2]= -(4*a)/(i*pi);
}
for(i=0;i<=n;i++)
{
cout<<A[i]<<"\t";
}
cout<<endl;
for(i=0;i<=n;i++)
{
cout<<B[i]<<"\t";
}
system("pause");
return(0);
}
```

I need to plot it using graphics functions.

Please help me with it.

Thanks.

Regards,

Harleen