fork download
  1. #include<stdio.h>
  2. #include<complex.h>
  3.  
  4.  
  5. #define N 100
  6. double ToNum(char *c);
  7.  
  8.  
  9. int main(){
  10.  
  11. double complex z1, z2, z3;
  12. char c1[N], c2[N];
  13. char *p = c1;
  14. char op;
  15. double imag, real,op1, op2;
  16.  
  17. scanf("%s%s%c", c1, c2, &op);
  18.  
  19. real = ToNum(c1);
  20. while (*p != '+' && *p != '-')
  21. p++;
  22. op1= *p == '+' ? 1 : -1;
  23. imag = ToNum(++p);
  24. imag *= op1;
  25. z1 = real+imag*I;
  26.  
  27. real = ToNum(c2);
  28. while (*p != '+' && *p != '-')
  29. p++;
  30. op2 = *p == '+' ? 1 : -1;
  31. imag = ToNum(++p);
  32. imag *= op2;
  33. z2 = real + imag*I;
  34.  
  35.  
  36. if (op == '+')
  37. z3 = z1 + z2;
  38. else if (op == '-')
  39. z3 = z1 - z2;
  40. else if (op == '*')
  41. z3 = z1*z2;
  42. else if (op == '/')
  43. z3 = z1 / z2;
  44.  
  45. printf("%lf%+lfi\n", creal(z3), cimag(z3));
  46.  
  47. return 0;
  48. }
  49.  
  50. double ToNum(char *c)
  51. {
  52. double num = 0;
  53. num = atof(c);
  54. return num;
  55. }
Compilation error #stdin compilation error #stdout 0s 2256KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘ToNum’:
prog.c:53:1: error: implicit declaration of function ‘atof’ [-Werror=implicit-function-declaration]
 num = atof(c);
 ^
cc1: all warnings being treated as errors
stdout
Standard output is empty