You are on page 1of 3

{

1. Sa se scrie o procedura care returneaza suma a doua numere intregi.


(diferenta,produs,cit,rest)

}
program P1;
var a,b:integer;
procedure return(a,b:integer);
var d,s,p,c,r:integer;
begin
s:=a+b;
d:=a-b;
p:=a*b;
c:=a div b;
r:=a mod b;

writeln(s);
writeln(d);
writeln(p);
writeln(c);
writeln(r);
end;
begin
writeln ('Introduceti cele 2 numere');
readln(a,b);
return(a,b);

end.

{
2. Se considera patru numere reale. Sa se determine numarul mai mare , utilizind
procedura
cu parametri care determina numarul mai mare din doua numere date.

}
program P2;
var a,b,c,d,max1,max2,max3,max4:integer;
procedure return(x,y:integer;var max:integer);
begin

max:=0;
if (x>y) then max:=x;
if (y>x) then max:=y;

end;
begin
max1:=0;
max2:=0;
max3:=0;
max4:=0;
writeln ('Introduceti cele 4 numere');
readln(a,b,c,d);
return(a,b,max1);
return(b,c,max2);
return(c,d,max3);
return(d,a,max4);
if (max1>max2) and (max1>max3) and (max1>max4) then writeln(max1)
else if (max2>max3) and (max2>max4) then writeln(max2)
else if (max3>max4) then writeln(max3)
else writeln(max4);
end.

{
5. De la tastatura se introduce un numar natural x. Sa se scrie o procedura care
afiseaza 0
daca x este par si 1 in caz contrar.
}
program P5;
var x:integer;
procedure par(a:integer);
begin
if (a mod 2 = 0) then writeln('0')
else writeln('1');
end;
begin
writeln ('Introduceti numarul');
readln(x);
par(x);
end.

{
6. De la tastatura se introduc 3 numere natural a,b,c. Determinatii toti divizorii
comuni ai
acestor numere utilizind o procedura ce determina multimea divizorilor unui numar
natural.

}
program P6;
var a,b,c:integer;
procedure return(a,b,c:integer);
var i:integer;
begin
for i:=1 to 1000 do
begin
if (a mod i=0) and (b mod i=0) and (c mod i=0) then writeln(i);
end;
end;
begin
writeln ('Introduceti numerele');
readln(a,b,c);
return(a,b,c);
end.

{
3. Se considera cinci numere reale. Sa se determine numarul mai mare , utilizind
procedura
cu parametri care determina numarul mai mare din trei numere date.

}
program P3;
var a,b,c,d,e,max1,max2,max3,max4:integer;
procedure return(x,y,z:integer;var max:integer);
begin

max:=0;
if (x>y) and (x>z) then max:=x;
if (y>x) and (y>z) then max:=y;
if (z>x) and (z>y) then max:=z;

end;
begin
max1:=0;
max2:=0;
max3:=0;
max4:=0;
writeln ('Introduceti cele 5 numere');
readln(a,b,c,d,e);
return(a,b,c,max1);
return(b,c,d,max2);
return(c,d,e,max3);
return(d,e,a,max4);
if (max1>max2) and (max1>max3) and (max1>max4) then writeln(max1)
else if (max2>max3) and (max2>max4) then writeln(max2)
else if (max3>max4) then writeln(max3)
else writeln(max4);
end.

You might also like