Question for routine in Pascal [closed]

-2

I need to write a routine that calculates a value and applies a percentage. Both the value and the percentage must be requested. Perform this calculation using a function, returning the final value with the percentage applied.

    
asked by anonymous 27.10.2018 / 03:57

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;
    
27.10.2018 / 04:27