Contoh Sourch Code program buble:
#include <iostream.h>
#include <conio.h>
void main()
{
  int data[100],a,max;
  cout<<" Masukkan Jumlah Data = ";cin>>max;
  for (int x=1;x<=max;x++)
   {
   cout<<" Data Ke "<<x<<"= ";cin>>data[x];
   }
   {
   cout<<endl;
   cout<<"data sebelum di urut: \n";
   cout<<endl;
   for(int k=1;k<=max;k++)
   cout<<data[k]<<" ";
   cout<<endl;
   }
   for(int i=1;i<=max-1;i++)
    for(int j=1;j<=max-1;j++)
     if ( data[j] > data[j+1])
      {
       a=data[j];
       data[j]=data[j+1];
       data[j+1]=a;
      }
    cout<<endl;
    cout<<"Data setelah diurutkan: \n ";
    cout<<endl;
    for(int k=1;k<=max;k++)
    cout<<data[k]<<" ";
    cout<<endl;
    getch();
}
Program Setelah Di Eksekusi:

Labels: Cplusplus