Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <complex.h>
- #include <cross_studio_io.h>
- void main(void)
- {
- double complex z1 = 1.0 + 3.0 * I;
- double complex z2 = 1.0 - 4.0 * I;
- debug_printf("Working with complex numbers:\n\v");
- debug_printf("Starting values: Z1 = %.2f + %.2fi\tZ2 = %.2f %+.2fi\n", creal(z1), cimag(z1), creal(z2), cimag(z2));
- double complex sum = z1 + z2;
- debug_printf("The sum: Z1 + Z2 = %.2f %+.2fi\n", creal(sum), cimag(sum));
- double complex difference = z1 - z2;
- debug_printf("The difference: Z1 - Z2 = %.2f %+.2fi\n", creal(difference), cimag(difference));
- double complex product = z1 * z2;
- debug_printf("The product: Z1 x Z2 = %.2f %+.2fi\n", creal(product), cimag(product));
- double complex quotient = z1 / z2;
- debug_printf("The quotient: Z1 / Z2 = %.2f %+.2fi\n", creal(quotient), cimag(quotient));
- double complex conjugate = conj(z1);
- debug_printf("The conjugate of Z1 = %.2f %+.2fi\n", creal(conjugate), cimag(conjugate));
- debug_exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement