Doubt for routine in Pascal

Asked

Viewed 36 times

-2

I need to write a routine that makes a calculation in which a value is informed and applied a percentage. Both the value and the percentage must be requested. Perform this calculation through a Function, returning the final value with the applied percentage.

1 answer

1

I suppose the following code solves your problem.

function calcPorcentagem(valor, porcentagem: integer): double;
var
   valorParcial: double;

begin
     // Calcula o valor percentual
    valorParcial := ((valor * porcentagem) / 100);

    // Soma ao valor inicial a porcentagem desejada
    calcPorcentagem := (valorParcial + valor);
end;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.