All pastes #2046591 Raw Edit

Someone

public c v1 · immutable
#2046591 ·published 2011-04-14 23:33 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>//Prototiposvoid funcao(float x);int main(){    funcao(0.5);    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){       float a,fx,dfx,precisao=0.0001;       int k=1;       printf("\nXo: %.4f\n",x);        fx = (((x*x*x)-(9*x))+3);        dfx = (3*(x*x)-9);                    while(modulo(fx)>precisao){           a = x - (fx/dfx);           k++;           x=a;           fx = (((x*x*x)-(9*x))+3);           dfx = (3*(x*x)-9);                                                   }        printf("Raiz: %.4f \niterações:%i\n",x,k); }