While..Do Loop
While..Do Loop
Do Loop
Output:
Code:
procedure TForm1.Button1Click(Sender: TObject);
Output:
Code:
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
Output:
Code:
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.