- #1
GustavoGG
- 2
- 0
- TL;DR Summary
- Im tring to use the library complex.h in C, but at the moment of compile and run it, the firsts times prints trash and then it runs well but after that one, again prints trash and thus, and i dont if the problem is with my computer or whats going on?
I send the next code to a friend and it runs him perfectly but not to me.
C:
#include<stdio.h>
#include<math.h>
#include<complex.h>
int main(){
float complex a,b,x=2,y,z;
printf("Write the real part followed by the imaginary part of your complex number: \n");
scanf("%f %f",&a,&b);
z=a+I*b;
printf("z= %f + i%f\n",creal(z),cimag(z));
y=cpow(z,x);
printf("z2= %f + i%f\n",creal(y),cimag(y));
return 0;
}
<< Mentor Note -- code tags added >>