fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. f(double x){
  5. double r=0;
  6. /**/
  7. printf("\n x= %f, f(x) = %f\n",x, pow(x,2)+6*x);
  8. /**/
  9. r = pow(x,2)+6*x;
  10. return r;
  11. }
  12. derivatef(double x, double
  13. return (( f(x+dx) - f(x) ) / dx);
  14. }
  15. void main(){
  16. double f_x, df_x; //d = derivada;
  17. /*
  18.   1- Usando o método da derivada à direita,
  19.   calcule f'(x) nos pontos x=-2 e 2.
  20.   Como você sabe se o valor encontrado é
  21.   correto sem calcular o valor analítico de f'(x) ?
  22.   */
  23. f_x = f(2);
  24. df_x = derivatef(2, 0.001);
  25. printf("x=2, f(x) = %f, f'(x) = %f", f_x, df_x);
  26. }
  27.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:4:1: error: return type defaults to 'int' [-Werror=implicit-int]
 f(double x){
 ^
prog.c:13:5: error: expected ';', ',' or ')' before 'return'
     return (( f(x+dx) - f(x) ) / dx);
     ^
prog.c:15:6: error: return type of 'main' is not 'int' [-Werror=main]
 void main(){
      ^
prog.c: In function 'main':
prog.c:24:12: error: implicit declaration of function 'derivatef' [-Werror=implicit-function-declaration]
     df_x = derivatef(2, 0.001);
            ^
cc1: all warnings being treated as errors
stdout
Standard output is empty