Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {* paulogp *}
- {* mac os 7 *}
- program Ada28p;
- uses
- MemTypes, QuickDraw, OSIntf;
- var
- x, old_guess, new_guess: real;
- tecla: string;
- begin
- repeat
- clearscreen;
- gotoxy(30, 2);
- writeln('Metodo de Newton');
- gotoxy(30, 3);
- writeln('~~~~~~');
- writeln;
- writeln;
- write('Insira o numero: ');
- readln(x);
- writeln;
- if x > 0.0 then
- begin
- new_guess:= x / 2;
- repeat
- old_guess:= new_guess;
- new_guess:= (old_guess + x / old_guess) / 2;
- until new_guess = old_guess;
- writeln('Raiz de ', x: 2, ' e ', new_guess: 3);
- end else
- if x = 0.0 then writeln('Raíz de ', x: 2, ' e ', x: 3) else
- writeln('Este programa funciona apenas com numeros positivos!');
- writeln;
- writeln;
- write('Repetir (s/n): ');
- readln(tecla);
- uprstring(tecla, true);
- until tecla = 'N';
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement