C : Complex Number Computation

In this post, I will create program C : complex number computation.

Are you know about complex number? A complex number is a number consisting of a real part and an imaginary part. Computation for real/integer number is different with complex number. In this tutorial, I am write how we can process complex number computation. Complex number computation from this code consists of :

  • cadd     : add two complex numbers
  • csub     : subtract two complex numbers
  • cmul    : multiply two complex numbers
  • cdiv     : divide two complex numbers
  • cmplx  :  make a complex number from two real numbers
  • conjg    : complex conjugate of a complex number
  • cneg    :  negate a complex number
  • cinv    : invert a complex number
  • csqrt   : complex square root of a complex number
  • cexp   : complex exponential of a complex number
  • crmul :  multiply a complex number by a real number
  • rcabs  : real magnitude of a complex number

This is a sample tes code how to process complex number compution, save this code as complex_computation.c :

This is example how to use and output for complex number computation above code :

You can download the complete source code complex number computation code at here.

Source :

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.