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.

By FlamingClaw

```
{
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=-
}
```

About the Author

Just living in hungary.Teaching myself in pascal.

I have time to programming when I'm going to home,cause my job is not a good place for that.

Don't forget that if you ask something on the forum and you got the right answer then

[b] mark as solved !![/b]