#include #include #include #include #include #include int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int midx, midy, i; /* initialize graphics, local variables*/ initgraph(&gdriver, &gmode, "g:\\bc31\\bgi"); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with error code */ } double realy,realy2,realy3,imgy,imgy2,imgy3,replot3,implot3; double abstract[2][10]={{0,0,0,2,2,2,2,0,0,0},{0,0,0,0,0,0,0,0,0,0}}; double theta,theta2,reSum[10],imSum[10]; int n,y,y2,ans; int a,k; int b; cout <<"Enter value for a wave : "; cin >>a; cout <>b; cleardevice(); { setlinestyle(SOLID_LINE,1,1); //code to redo graph each time moveto(40,40); lineto(40,160); moveto(40,100); lineto(260,100); moveto(400,40); lineto(400,160); moveto(400,100); lineto(620,100); setlinestyle(SOLID_LINE,1,1); //code to redo graph each time moveto(40,170); lineto(40,290); moveto(40,230); lineto(260,230); moveto(400,170); lineto(400,290); moveto(400,230); lineto(620,230); setlinestyle(SOLID_LINE,1,1); //code to redo graph each time moveto(40,300); lineto(40,420); moveto(40,360); lineto(260,360); moveto(400,300); lineto(400,420); moveto(400,360); lineto(620,360); for(k=0;k<10;k++) { reSum[k]=0; imSum[k]=0; for(n=0; n<10; n++) //loop to calc each value of n { theta = 2*M_PI*k*n/10.0; // y= 100-60*cos(theta); realy = cos(theta); // moveto(40+22*n,100); // lineto(40+22*n,y); // y= 100-60*sin(theta); imgy = sin(theta); // moveto(400+22*n,100); // lineto(400+22*n,y); //to get the scaler product of the a and b realy3=((realy * abstract[0][n])-(imgy * abstract[1][n])); imgy3=((realy * abstract[1][n])+(abstract[0][n] * imgy)); reSum[k] += realy3; imSum[k] += imgy3; } //end for n loop }// end for k loop cout<<"resum : "<