Pelles C forum

C language => Beginner questions => Topic started by: techniker1986 on February 24, 2011, 02:09:11 PM

Title: What is wrong?
Post by: techniker1986 on February 24, 2011, 02:09:11 PM
#include <stdio.h>
#include <complex.h>
#include <math.h>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

complex double parallel (complex double, complex double);
int main  (void)
{

 complex double z, zl, zc, zr;
 zr=6.9;
 zl=I*2*3.14159265358979323846*549000*0.0002;                               //for 3.14159265358979323846 -> M_PI
 zc=1/(I*2*3.14159265358979323846*549000*0,0000000005);               //for 3.14159265358979323846 -> M_PI
 z=parallel (zl+zr, zc);


 printf ("Wirkanteil=%lf Ohm\n", creal (z));
 printf ("Blindanteil=%lf Ohm\n\n", cimag(z));

 printf ("Betrag=%lf Ohm\n", cabs(z));
 printf ("Phi im Bogenmass=%lf Rad\n", carg(z));
}
 complex double parallel (complex double a, complex double b)
{
 return ((a*b)/(a+b));
}

thanks for helo
Title: Re: What is wrong?
Post by: CommonTater on February 24, 2011, 06:07:02 PM
Ok... what is it doing wrong?

A little more information would be helpful....
Title: Re: What is wrong?
Post by: frankie on February 24, 2011, 06:26:56 PM
Code: [Select]
#include <stdio.h>
#include <complex.h>
#include <math.h>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

complex double parallel (complex double, complex double);
int main  (void)
{

 complex double z, zl, zc, zr;
 zr=6.9+I*0.0;
 zl=0.0+I*2*3.14159265358979323846*549000*0.0002;                               //for 3.14159265358979323846 -> M_PI
 zc=0.0+I*1/(2*3.14159265358979323846*549000*0,0000000005);               //for 3.14159265358979323846 -> M_PI
 z=parallel (zl+zr, zc);


 printf ("Wirkanteil=%lf Ohm\n", creal (z));
 printf ("Blindanteil=%lf Ohm\n\n", cimag(z));

 printf ("Betrag=%lf Ohm\n", cabs(z));
 printf ("Phi im Bogenmass=%lf Rad\n", carg(z));
}
 complex double parallel (complex double a, complex double b)
{
 return ((a*b)/(a+b));
}
Title: Re: What is wrong?
Post by: MichaelT on February 24, 2011, 06:33:28 PM
(0 -->,<-- 0000000005)
Title: Re: What is wrong?
Post by: CommonTater on February 24, 2011, 06:35:36 PM
(0 -->,<-- 0000000005)

Wow... nice catch!
Title: Re: What is wrong?
Post by: techniker1986 on February 24, 2011, 10:39:24 PM
ok thanks