ComplexCords
4 years ago in C
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char const *argv[]) {
double x, y;
printf("Insert real number first, then imaginary y part\n");
while(1) {
scanf(" %lf", &x);
scanf(" %lf", &y);
double abs = pow(x, 2) + pow(y, 2);
double r = sqrt(abs);
double phi = acos(x / r);
if(y < 0)
phi *= (-1);
printf("\nr = sqrt( %lf ) = %.4lf\n", abs, r);
printf("phi = %.4lf\n\n", phi);
printf("cartesian: x = %lf; y = %lf\n", x, y);
printf("trigonometric: %lf * ( cos( %lf ) + i * sin( %lf ))\n", r, phi, phi);
printf("exponential: %lf ^ ( i * %lf)\n", r, phi);
}
return 0;
}