DELPHI CODE Flashcards

1
Q

ffcurrency

A

formats the value with the currency included

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

ffexponent

A

formats the value in scientific notain

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

fffixed

A

formats the value with the number of decimals as specified

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

string

A

address:=inputbox(‘address’,’enter the address’,’ ‘);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

example using ffcurrency

A

redoutput.lines.add(‘final amount’+#9+floattostr(rfinalamount,ffsurrency,6,2));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

ffgeneral

A

general number format. Includes decima;s oly when required

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

ffnumber

A

corresponds to fffixed , but uses thousands separator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

integer

A

icount:= strtoint(iputbox(‘amount’,’enter the amount’,’ ‘);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

real

A

rsales:=strtoint(inputbox(‘sales’, ‘please enter the sales figure’ ,’ ‘));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

char

A

cclass:= inputbox(‘class’ , ‘ please enter the class ‘ , ‘ ‘)[1];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

general structure of the if statement

A

if <conditions> then
begin</conditions>

<statements> ;
end
else
begin
<statements> ;
end;
</statements></statements>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

case statement example

A

if imark>=80 then
csymbol:=’A’;
else
if imark>=70 then
csymbol:=’B’’;
else
if imark>=80 then
csymbol:=’A’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

the while loop

A

var
isum , inumber :integer;

begin
isum:= 0;
inumber:= 1;

while inumber <10 do
begin
isum:=isum +inumber ;
inumber := inumber +2 ;
end ;

redoutput.lines.add(inttostr(isum));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

declaring an array

A

var
frmarray:tfrmarrays;
rrnumber:array[1..100] of integer;
icount: integer ;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

load numbers from a textfile into an array

A

var
tf:textfile;
stemp: string ;

begin
icount := 0;
assignfile(tf, ‘numbers.txt’);
reset (tf);

while not eof(tf) do
begin icount:= icount+1 ;
readln (tf,stemp );
arrnumbers [icount]:= strtoint(stemp ) ; end ;
closefile (tf) ;
end ;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

remove numbers that repeat in an array

A

var
ioutbound ,iinbound,ireplace : integer;

begin
for ioutbound := 1 to icount -1 do
begin
for iinbound:= ioutbound +1 to icount do
begin
if arrnumbers [ioutbound]= arrnumbers [iinbound ]
then
begin
for ireplace :=ioutbound to icount do
begin
arrnumbers[ireplace]:= arrnumbers [ireplace+1];
end;
end;
end;
end;

13
Q

show numbers from an array in a richedit

A

var
iforcount : integer;

begin
redoutput.clear ;
for iforcount:= 1 t icount do
begin
redoutput.lines.add(inttoatr(arrnumbers[iforcount]));

14
Q

find number (Item ) in an array

A

var
iforcount :iteger;
isearch:integer;
begin
isearch:= strtoint(edtfind.text);
for iforcount :=1 to icount do
begin
if isearch := arrnumbers[foricout] then
begin
showmessage (‘nummber found at :’ + inttostr(iforcount));
exit;
end;
end;
end;

15
Q

binary search in an array

A

var
iforcount :integer;
isearch , ilowbound ,iupbound , imiddle ,iposition : integer ;
bfound : boolean ;

begin
bfound := false ;
ilowbound :=1;
iupbound:=icount;
ipostion:= 0;
isearch:= strtoint(edtfind.text);

while (ilowbound<= iupbound) and ( bfound =false )
do
begin
imiddles :+ (ilowbound +iupbound ) di 2 ;
if isearch =arrnumber [imiddles ] then
begin
iposition:= imiddle;
bfound := true ;
end
else
if isearch > arrnumbers [imiddle ] then
ilowbound := imiddle+1 else
iupbound :=imiddle -1 ;
end ;

if bfound =true then
begin
showmeassage (‘number found at:’+ inttostr(ipostion ) );
end
else
begin
showmessage (‘number not found);
end
end ;

16
Q

selection sort

A

var
icountout , icountcomp, itemp :integer;

begin
for icountout :=1 to icount do
begin
for icountcomp:= icountout to icount do
begin
if arrnumbers [icountout]> arrnumbers [icountcomp]
then
begin
itemp:= arrnumbers [icountout];
arrnumbers[icountout]:=arrnumbers [icountcomp];
arrnumbers [icountcomp]:=itemp;
end;
end;
end;
end;

17
Q

bubble sort

A

var
itemp, icounter : integer;
bswap :boolean ;
begin

bswap:= true;
for icounter:= 1 to icount -1 do
begin
if arrnumbers [icounter]>arrnumbers [icounter+1] then
begin

itemp:= arrnumbers [icounter];
arrnumbers

18
Q
A