• Lenguaje

    Pascal

  • Descripción

    Calcular la siguiente función matemática, donde el valor de x debe ser un número entero positivo:
    f(x)=2x³-3x²+√5x

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
program _2X33X25X;
uses crt, math;

var fx, x : real;
begin
    write ('Ingresa el valor de x: ');
    readln (x);
    fx := 0;
    if x>=0 then
        begin
            fx := 2.0*x*x*x+3.0*x*x+sqrt(5.0*x);
        end
    else
        begin
            writeln ('Error: ra'#161'z de n'#163'mero negativo.');
        end;
    writeln ('Valor de fx: ', fx:0:6);
    writeln;
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.