```
{
Question
This algorithm will decide that is there a serched element
in the array.If it finds one then the loop halts.If the loop
halts cause we're stepping over the last element of the array then
there is not searched element.
Is there 'u' in the array?
u is a variable.
i:=1
While i<=N Ã©s T[i]<>u
i:=i+1
End of while
If i<=N Then out: there is,u
Else out:there isn't,u
Note that important the order of conditions!!!
}
Program Solution01;
Const n=20;
Var i,u:Integer;
T:Array[1..n]Of Integer;
Begin {main}
Write('Give me a number between 1 and 20: ');
ReadLn(u);
Randomize;
For i:=1 To n Do Begin
T[i]:=Random(n)+1;
Write(T[i],',');
End;
WriteLn;
i:=1;
While (i <= n) And (T[i]<>u) Do Begin
i:=i+1;
End;
If i<=n Then Write('There is: ',u)
Else Write('There is not: ',u);
ReadLn;
End.
{
-= Note By FlamingClaw =-
All programs created by me are written and tested
in Dev Pascal and/or Turbo Pascal 7.0
Of course working!
-= Created By FlamingClaw =-
-=2009.04.05=-
}
```

1

Contributor0

Replies2

Views**Are you able to help answer this sponsored question?**

Questions asked by members who have earned a lot of community kudos are featured in order to give back and encourage quality replies.

Recommended Topics