Computer Science Blog

June 13, 2007

Program Array 2

Filed under: Pascal Programming

uses wincrt;

   var
     L : array[1..100] of integer;
     index,i,n,X : byte;
     ketemu : boolean;
                                 
   begin
        write(’Masukkan jumlah data : ‘);
        readln(n);

        randomize;

        writeln(’Data ke yang dimasukkan adalah ‘);

        for i:=1 to N do
        begin
             L[i]:=random(100)+1;
             write(L[i]:4);
        end;

        writeln;
        write(’Mau cari Nilai berapa ? ‘);readln(X);

        writeln;
        ketemu := false;
       
        for i:=1 to N do
        begin
             if l[i] = x then
             begin
                ketemu := true;
                index := i;
             end;
        end;

        if ketemu then
           writeln(’Nilai ‘,X,’ ditemukan pada index ke - ‘,index)
        else
           writeln(’Nilai ‘,X,’ TIDAK ditemukan’);

        readkey;
        donewincrt;
   end.

Comments »

The URI to TrackBack this entry is: http://gudeg.blogsome.com/2007/06/13/program-array-2/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Get free blog up and running in minutes with Blogsome
Theme designed by Jay of onefinejay.com