NO

Author Topic: What is wrong?  (Read 3779 times)

techniker1986

  • Guest
What is wrong?
« 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

CommonTater

  • Guest
Re: What is wrong?
« Reply #1 on: February 24, 2011, 06:07:02 PM »
Ok... what is it doing wrong?

A little more information would be helpful....

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: What is wrong?
« Reply #2 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));
}
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

MichaelT

  • Guest
Re: What is wrong?
« Reply #3 on: February 24, 2011, 06:33:28 PM »
(0 -->,<-- 0000000005)

CommonTater

  • Guest
Re: What is wrong?
« Reply #4 on: February 24, 2011, 06:35:36 PM »
(0 -->,<-- 0000000005)

Wow... nice catch!

techniker1986

  • Guest
Re: What is wrong?
« Reply #5 on: February 24, 2011, 10:39:24 PM »
ok thanks