Today we are going to share a **C program to add two complex numbers**. If you are a beginner and want to start learning the C programming, then keep your close attention in this tutorial as I am going to share a C program to add two complex numbers with the output.

We have designed this program for beginners for learning purpose. Copy below c program and execute it with c compiler to see the output of the program.

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 | #include <stdio.h> struct complex { int realpart, imaginary; }; main() { struct complex a, b, c; printf("Enter value of a and b complex number a + ib.\n"); printf("value of complex number a is = "); scanf("%d", &a.realpart); printf("value of complex number b is = "); scanf("%d", &a.imaginary); printf("Enter value of c and d complex number c + id.\n"); printf("value of complex number c is = "); scanf("%d", &b.realpart); printf("value of complex number d is = "); scanf("%d", &b.imaginary); c.realpart = a.realpart + b.realpart; c.imaginary = a.imaginary + b.imaginary; if (c.imaginary >= 0) printf("complex numbers sum is = %d + %di\n", c.realpart, c.imaginary); else printf("complex numbers sum = %d %di\n", c.realpart, c.imaginary); return 0; } |

Enter value of a and b complex number a + ib.

value of complex number a is = 10

value of complex number b is = 5

Enter value of c and d complex number c + id.

value of complex number c is = 20

value of complex number d is = 25

complex numbers sum is = 30 + 30i

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

- C Program For Infix To Postfix Conversion and Evaluation of postfix expression
- Greedy Change Making Program in C
- C Program to find Binomial Coefficients
- C program to remove consecutive repeated characters from string
- C Program to Read and Print details of 50 Students using Structure
- C program to Use structure within union & display the contents of structure elements
- C program to find area of scalene triangle
- C program to implement bit flipping
- C program to implement hashing
- C program to implement SJF algorithm

We use cookies to ensure that we give you the best experience and use cookies in order to personalize the advertising that you see on our website. Read more about our Privacy Policy.Got it!