fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. double resf(double a)
  4. {
  5. return 1/(4-a*a*a*a);
  6. }
  7. double calc_eps()
  8. {
  9. double eps=1.0;
  10. while(1.0+eps>1.0)
  11. eps/=2.0;
  12. return eps;
  13. }
  14.  
  15. double calc_func(double x,double eps,int i)
  16. {
  17. double up=1.0,down=4.0,res=up/down;
  18. i=1;
  19. while(res>eps && i<=100)
  20. {
  21. up*=4;
  22. down*=pow(x,4);
  23. res+=up/down;
  24. i++;
  25. }
  26. return res;
  27. }
  28.  
  29.  
  30.  
  31.  
  32. int main()
  33. {
  34. double eps=calc_eps();
  35. printf("eps=%lf\n",eps);
  36. double res,x;
  37. int j=0,n=1.0/0.05;
  38. for(j<=n,j++);
  39. {
  40. x=j*0.05;
  41. res=calc_func(x,eps,i);
  42. printf("|lf%|20lf%|20lf%|20lf%|d%|",x,res,resf,fabs(resf(x)-res),i);
  43. }
  44. return 0;
  45. }
  46.  
  47.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:38:10: warning: left-hand operand of comma expression has no effect [-Wunused-value]
  for(j<=n,j++);
          ^
prog.c:38:14: error: expected ‘;’ before ‘)’ token
  for(j<=n,j++);
              ^
prog.c:38:14: error: expected expression before ‘)’ token
prog.c:38:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
  for(j<=n,j++);
  ^~~
prog.c:39:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘for’
  {
  ^
prog.c:41:23: error: ‘i’ undeclared (first use in this function)
   res=calc_func(x,eps,i);
                       ^
prog.c:41:23: note: each undeclared identifier is reported only once for each function it appears in
stdout
Standard output is empty