We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,304 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Make Validation in Looping

Uses crt;
Const M=5;
Var
A : array [1..M] of Integer;
i,x : Integer;
dapat : boolean;

Function Cek(angka:Integer;batas:Integer):string;
var
Awal:integer;
Begin
For awal:=1 to batas do
Begin
If A[awal]=angka then
Begin
Cek:='Angka Sudah Ada !';
dec(i);
End
Else
Cek:='Angka benar !';
End;
End;

Begin
Clrscr;
Writeln('Pencarian dengan fungsi Logika');
Writeln;

For i:=1 to M do
Begin
Write('Masukkan angka indeks ',i,' : ');Readln(A);
Writeln(Cek(A,i-1));
Writeln;
End;

Write('Angka yang dicari : ');Readln(x);
Writeln;
dapat:=false;
i:=1;

While (i<=M) and (not dapat) do
Begin
If A=x then Dapat:=True
Else
inc(i);
End;

If A=x then
Writeln('Angka ditemukan pada indeks ke-',i,' = ',A)
Else
Writeln('Maaf ! Angka tidak ditemukan');

Readln;
End.

Confuse, Need Help ?

2
Contributors
3
Replies
3 Days
Discussion Span
1 Year Ago
Last Updated
4
Views
hasbi
Newbie Poster
3 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Confused about what ?

pritaeas
Posting Prodigy
Moderator
9,309 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,464
Skill Endorsements: 86

Confuse in information condition, in cek function

hasbi
Newbie Poster
3 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Try to explain in plain English what you want to add to your code.

pritaeas
Posting Prodigy
Moderator
9,309 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,464
Skill Endorsements: 86

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0648 seconds using 2.65MB