Sites Grátis no Comunidades.net Criar uma Loja Virtual Grátis

Página Pessoal de José António Mendes Silva


Rating: 2.5/5 (394 votos)




ONLINE
1







Total de visitas: 1035618
Pascal

Dicas sobre a linguagem de programação Pascal.

Converter inteiro para real e viceversa

program Int_To_Real_To_Int;
var Inteiro:integer;
      NumReal:real;
begin
   writeln;
   writeln(' Digite um númer Real');
   writeln;
   Inteiro:= Round(((NumReal * valorInt) / valorReal));
   { Ou:
    Inteiro:= DoubleToInt(((NumReal * valorInt) / valorReal));
   }

   writeln(' Resultado ',Inteiro);
end.

 

Trabalhando com arrays dinâmicos

program arrayDinamico;
uses crt;
 var
 Vector: array of Integer;
 k : integer;

 begin
   SetLength(Vector, 10) ;
   for k := Low(Vector) to High(Vector) do
     Vector[k] := k*10;

   writeln('Primeira parte do calculo');
   for k := Low(Vector) to High(Vector) do
     writeln(Vector[k]);
     readln;

   writeln('Segunda parte do calculo');

   //Aumentando o espaco
   SetLength(Vector, 20) ;
   //Agora o Vector array pode aumentar para 20 elementos
   for k := 10 to High(Vector) do
     Vector[k] := k+5;

   for k := Low(Vector) to High(Vector) do
     writeln(Vector[k]);
     readln;
 end.