# Truncate and If statement with "is not a whole number"

• 03-05-2013, 12:37 PM
renzzy
Truncate and If statement with "is not a whole number"
Our prof. gave us this pseudocode...he wants us to research and transform it into an actual program...

i'm having a big problem on this part of the pseudocode

if(Interval is not a whole number) then
{
truncate interval
}

how can i use a if statement in determining if it is a decimal or a whole number??

and how do i use truncate??
truncating it into ones twos or threes...

this code has an array of 14 names i didn't include them

Pseudocode
Shell_Sort(Arr,N)
{
If(N=1) then
{
Exit
}
Set Interval to N
while(Interval is not 1)
{
Set Interval to ((Interval/3)+1)
If(Interval is not a whole number) then
{
Truncate Interval
}

Set start to 1
while(start <= Interval)
{
Sort()
Increment start
}
}
}

sort()
{
set Unsrt_Indx to (start + interval)

while(unsrt_Indx <= N)
{
if (Arr[Unsrt_Indx - Interval] > arr[unsrt_Indx] then
{
set str_indx to unsrt_indx
set temp to arr[srt_indx]

while((str_indx >start && (arr[str_indx-Interval] > temp))
{
set arr[set_indx] to arr[str_index- interval]
set str_indx to (crt_index - interval)
}

set arr[str_indx] to temp
}

set unsrt_indx to (unsrt_indx + interval)
}
}