Monday, 3 June 2013

Sum of Two Complex Numbers in C

  C99 has a header file called <complex.h> which contains functions and macros to manipulate complex numbers. C99 also adds _Complex keyword to deal with complex numbers. But in this small program I have used C89 syntax and double data type to deal with complex numbers.

int main()
    double re1,im1,re2,im2,re3,im3;
    printf("\n\nThe format of Complex Number is a+bi\n\n");
    printf("\nEnter the First Complex number:  ");
    printf("\nEnter the Second Complex number:  ");
    printf("\nThe Sum = %lf+%lfi\n",re3,im3);
    return 0;

Figure Below Shows a Sample Output

No comments:

Post a Comment