All pastes #2046607 Raw Edit

Someone

public c v1 · immutable
#2046607 ·published 2011-04-15 00:19 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>//Prototiposvoid funcao();float modulo(float x);int main(){    funcao();    system("pause");    return 0;}float modulo(float x){    if (x>=0.0){      return (x);}    else{       return (-1.0*x);    }}//Funcao que calcula a funcaovoid funcao(){       float x,a,fx,dfx,precisao=0.0001;       int k=0;       printf("Informe o valor de Xo: ");       scanf("%f",&x);       fx = (((x*x*x)-(9*x))+3);        dfx = (3*(x*x)-9);                   a = x - (fx/dfx);        printf("valor de x %.4f\n",a);        while(modulo(fx)>precisao){           x=a;           k++;           fx = (((x*x*x)-(9*x))+3);           dfx = (3*(x*x)-9);           a = x - (fx/dfx);           // printf("valor de fx %.10f\n",modulo(fx));                                   }        printf("Raiz: %.4f \niterações:%i\n",x,k); }