0% found this document useful (0 votes)
4 views4 pages

While..Do Loop

The document outlines three applications created using Delphi. The first application displays user-inputted numbers, the second converts a number to binary, and the third displays even and odd numbers while calculating their sum and average. Each application includes code snippets demonstrating the implementation of the described functionalities.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

While..Do Loop

The document outlines three applications created using Delphi. The first application displays user-inputted numbers, the second converts a number to binary, and the third displays even and odd numbers while calculating their sum and average. Each application includes code snippets demonstrating the implementation of the described functionalities.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

While..

Do Loop

Statement of the Problem:

1. Create an application that will display your inputted numbers

depending on how many numbers you want to display.

Output:

Code:
procedure TForm1.Button1Click(Sender: TObject);

var COK:Boolean; COK:=InputQuery('Input


num:string; Integer','Number',num);
x:integer; if COK then
[Link](num);
begin x:=strtoint(num);
[Link]; end;
x:=1; end;
while (x<>0) do end.
begin
num:='0';
Statement of the Problem:

2. Create an application that will convert a number into binary


numbers.

Output:

Code:

procedure TForm1.Button1Click(Sender: TObject);


var x,ctr:integer;
num:string;
xd,xm:integer;

begin
x:=strtoint([Link]);
num:='';
ctr:=x;
while (ctr<>0) do
begin
xd:=ctr div 2;
xm:=ctr mod 2;
num:=inttostr(xm) + num;
ctr:=xd;
end;
[Link]:=num;
end;
end.
Statement of the Problem:

3. Create an application that will display the even and odd numbers
and

compute the average and sum of the number inputted.

Output:

Code:

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;


Shift: TShiftState);

var COK:Boolean;
num:string;
ctr,x:integer;
sumo,sume:integer;
aveo,avee:real;

begin
if key=VK_Return then
begin
x:=strtoint([Link]);
sumo:=0;
sume:=0;
ctr:=1;
[Link];
[Link];
while ctr<=x do
begin
num:='0';
COK:=InputQuery('Sample','Number'+inttostr(ctr),num);
if COK then
begin
if (strtoint(num)mod 2=1) then
begin
[Link](num);
sumo:=sumo+strtoint(num);
end
else
begin
[Link](num);
sume:=sume+strtoint(num);
end;
end;
ctr:=ctr+1;
end;
[Link]('sum='+inttostr(sumo));
aveo:=sumo/x;
[Link]('ave='+floattostr(aveo));
[Link]('sum='+inttostr(sume));
avee:=sume/x;
[Link]('ave='+floattostr(avee));
end;
end;
end.

You might also like