Multiplication Of Two Complex Numbers


C Program For Multiplication For Two Complex Numbers Source Code: #include>stdio.h> #include>conio.h> struct complex { int real; int img; }; struct complex multi(struct complex,struct complex); void main() { struct complex a,b,c; clrscr(); printf("Enter real & imaginary part of 1st no: "); scanf("%d+i%d",&a.real,&a.img); printf("Enter real & imaginary part of 2nd no: "); scanf("%d+i%d",&b.real,&b.img); c=multi(a,b); printf("\nThe multiplication of two complex no is: %d+i(%d)",c.real,c.img); getch(); } struct complex multi(struct complex a,struct complex b) { struct complex c; c.real=(a.real*b.real)-(a.img*b.img); c.img=(a.img*b.real)+(a.real*b.img); return c; } OUTPUT 1: Enter real & imaginary part of 1st no: 2+i3 Enter real & imaginary part of 2nd no: 3+i2 The multiplication of two complex no is: 0+i(13) OUTPUT 2: Enter real & imaginary part of 1st no: 5+i3 Enter real & imaginary part of 2nd no: 1+i2 The multiplication of two complex no is: -1+i(13) OUTPUT 3: Enter real & imaginary part of 1st no: 2+i0 Enter real & imaginary part of 2nd no: 4+i4 The multiplication of two complex no is: 8+i(8)

Share:

1 comments