Buble Sort Program in Pascal

Hello, every one we know Pascal, right. Yup for some programmers or the ones who study in Informatics majors, of course we know about this software development, even with Delphi these days, we can make our program be easy with grafical user interface. In this section, we can try to make Bublle sort program, all we have to do is easy, just write source code bellow in Pascal for window or even in Delphi using Console application, here we are..

program bubble_sort_Ngesort;
uses wincrt;
type data=array[1..100] of integer;

procedure masukan(var x:data;n:integer);
var i:integer;
begin
for i:=1 to n do
begin
write('Masukkan data ke ',i,' = ');readln(x[i]);
end;
end;

procedure bubblesort(var x:data;n:integer);
var i,j:integer;t:byte;
begin
for i:=1 to n-1 do
for j:=1 to n-1 do
if x[j]>x[j+1] then
begin
t:=x[j];
x[j]:=x[j+1];
x[j+1]:=t;
end;
end;

procedure tampil(x:data;n:integer);
var i:integer;
begin
for i :=1 to n do
writeln(x[i]);
end;

var y:data;m:integer;
begin
clrscr;
write('masukkan jumlah data = ');readln(m);
masukan(y,m);
writeln;
writeln('Data sebelum diurutkan = ');
tampil(y,m);
bubblesort(y,m);
writeln;
writeln('Data setelah diurutkan =');
tampil(y,m);
end.

The lats, of course, Run the program and fill data :).
Created By Ader

Popular posts from this blog

Introduction to Use Case Diagram - Case study: Facebook

Kenapa tidak berkurban?

Sequential Search