-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq10_corrected.txt
41 lines (33 loc) · 830 Bytes
/
q10_corrected.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Online C compiler to run C program online
#include <stdio.h>
struct complex {
int a[2];
int b[2];
int c[2];
} comp;
int main() {
int j;
printf("Enter the real and imaginary parts of a:\n");
for (j = 0; j < 2; j++) {
scanf("%d", &comp.a[j]);
}
printf("Enter the real and imaginary parts of b:\n");
for (j = 0; j < 2; j++) {
scanf("%d", &comp.b[j]);
}
int mulr1 = 0;
int muli1 = 0;
int mulr2 = 0;
int muli2 = 0;
mulr1 = comp.a[0] * comp.b[0];
muli1 = comp.a[1] * comp.b[1];
mulr2 = comp.a[0] * comp.b[1];
muli2 = comp.a[1] * comp.b[0];
int rreal;
rreal = mulr1 - muli1;
int iimag;
iimag = mulr2 + muli2;
printf("Result of a x b is:\n");
printf("C = %d i + %d\n", rreal, iimag);
return 0;
}