Caricare documenti e articoli online 
INFtub.com è un sito progettato per cercare i documenti in vari tipi di file e il caricamento di articoli online.


 
Non ricordi la password?  ››  Iscriviti gratis
 

Questi sono 2 problemi standard in linguaggio di programmazione pascal(per seconda superiore)

elettronica





Questi sono 2 problemi standard in linguaggio di programmazione pascal(per seconda superiore)







CALCOLARE LA POTENZA ESP-ESIMA(SIA CON INDICE PO 414i83e SITIVO CHE NEGATIVO) DI UN NUMERO QUALUNQUE N.


Program potenza;

uses crt;

var n, pot: real;    esp, i : integer;

Begin



clrscr;

writeln('Fare la potenza di un qualunque numero n ');

write('Inserire n : ');

readln(n);

write('Inserire esponente : ');

readln(esp);


if n = 0 then if esp = 0 then writeln(' Indeterminato ')

else writeln('Risulta 0')

else if esp = 0 then witeln('Risulta 1')

else Begin

pot : = 1;

for i : = 1 to abs(esp) do

pot : = pot*n;


if esp < 0 then pot : = 1/pot;

writeln('Il risultato è ',pot:10:3)

end;

repeat until keypressed;

end.










CALCOLARE TUTTI IPOSSIBILI DIVISORI DI UN NUMERO



Program:divisori;

uses crt;

var n, a:integer;  c: real;

Begin

clrscr;

writeln('Inserire un numero n e calcolare tutti i divisori');

write('Inserire n : ');

readdln(n);

if n = 0  then writeln('Zero fratto qualsiasi numero dà 0')

else Begin

a : = n ;

Repeat c : = n/a;

if frac(c) = 0 then writeln(c:6:2);

a : = a - 1;

until a < = 1;

end;

repeat until keypressed;

end. 




Privacy




Articolo informazione


Hits: 1583
Apprezzato: scheda appunto

Commentare questo articolo:

Non sei registrato
Devi essere registrato per commentare

ISCRIVITI



Copiare il codice

nella pagina web del tuo sito.


Copyright InfTub.com 2024