// Given two sets of complex numbers, the first set contains 3 numbers and the // second set contains 2 numbers.thsi program outputs all the possible imaginary numbers that are the multiplications of // all complex numbers in the first set with those in the second. Note that the // size of this set will be 6. // Author:rahule@cse.iitk.ac.in #include main() { double a[2][3],b[2][2],real,img; int i,j; printf("\nfist set"); printf("\n----------"); for(i=0;i<3;i++) //read the first set of imaginary numbers in 'a' { printf("\nenter the real part of the number :"); scanf("%lf",&a[0][i]); printf("\nenter the imaginary part of the number :"); scanf("%lf",&a[1][i]); } printf("\nthe first set has been entered\n"); printf("\nsecond set"); printf("\n----------"); for(i=0;i<2;i++) //read the second set of imaginary numbers in set 'b' { printf("\nenter the real part of the number :"); scanf("%lf",&b[0][i]); printf("\nenter the imaginary part of the number :"); scanf("%lf",&b[1][i]); } printf("\nthe second set has been entered\n"); printf("\nthe all possible products are ,"); for(i=0;i<3;i++) for(j=0;j<2;j++) { real=a[0][i]*b[0][j]; //multiply ith number in set a with jth number in ser b,and store in real,img img=a[1][i]*b[1][j]; //now prints 'real + i img' //note that if imaginary part is negative,we should print "real - i img",NOT 'real i-img' printf("\n(%lf",a[0][i]); if(a[1][i]<0) printf(" - i %lf)",-(a[1][i])); else printf(" + i %lf)",a[1][i]); printf("*(%lf",b[0][j]); if(b[1][j]<0) printf(" - i %lf)",-(b[1][j])); else printf(" + i %lf)",b[1][j]); printf(" = (%lf",real); if(img<0) printf(" - i %lf)",-(img)); else printf(" + i %lf)",img); } printf("\n"); }