I need help any one please :(

Discussion in 'C' started by C-newbie, Mar 19, 2013.

  1. C-newbie

    C-newbie New Member

    Joined:
    Mar 19, 2013
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi evry one im new to this and C programming and looking for any one to help me with my asignment as I have no idea what to do......so i have to build a program to do with complex numbers ......i have to be able to convert them from rectangular form to circular and back again.....I will pm all the detail if any one is willing to help out......any help is apreciated thanks.
     
  2. DRK

    DRK New Member

    Joined:
    Apr 13, 2012
    Messages:
    44
    Likes Received:
    3
    Trophy Points:
    0
    Code:
    #include <math.h>
    
    struct complex_rectangular
    {
        double real;
        double imaginary;
    };
    
    struct complex_polar
    {
        double absolute;
        double argument; // angle in radians
    };
    
    typedef struct complex_rectangular complex_rectangular_t;
    typedef struct complex_polar complex_polar_t;
    
    
    complex_polar_t convertRectangularToPolar(complex_rectangular_t rectangular)
    {
        complex_polar_t polar;
        polar.absolute = sqrt(pow(rectangular.real, 2) + pow(rectangular.imaginary, 2));
        polar.argument = atan(rectangular.imaginary / rectangular.real);
        return polar;
    }
    
    complex_rectangular_t convertPolarToRectangular(complex_polar_t polar)
    {
        complex_rectangular_t rectangular;
        rectangular.real = polar.absolute * cos(polar.argument);
        rectangular.imaginary = polar.absolute * sin(polar.argument);
        return rectangular;
    }
     
  3. C-newbie

    C-newbie New Member

    Joined:
    Mar 19, 2013
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi DRK thank you very much ....sorry for such a late reply i had no access to the net was away for a while ....once again thank you very much im gone try to run that and i will get back to you in a bit :D
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice