ar_one_to. Diberdayakan oleh Blogger.
RSS

program mencari kpk

KPK is a continuation of the Guild's Smallest Multiples.
The definition of multiples are multiples of a number.
Example: Multiples of the number 3 is 3, 6, 9, 12, 15, ... (etc. ..)
Another example: Multiples of the number 4 is 4, 8, 12, 16, 20, ... (etc. ..)
Examples go again: Multiples of the number 6 is 6, 12, 18, 24, 30 ... (and so on ..)
Here also made a program using the C language, this program can help to find a KPK. Consider the following source code:

#include
#include

using namespace std;

    class kpk {
  public:
     void input();
     void output();
     void proses();

  private:
        int a,b,c;
        int nilai;
   };

    void kpk::input(){
    cout<<"Masukkan Nilai Bil A : "; cin>>a;
    cout<<"Masukkan Nilai Bil B : "; cin>>b;
        }

void kpk::proses(){
    for(int x=1;x<=b;x++)
    nilai=nilai+a;
    if(nilai % b==0);
}

void kpk::output()
{

proses();
cout<< " KPK Antara " << a << " dan " << b << " Adalah " << nilai << endl;
}

int main(){

kpk bilangan;
bilangan.input();
bilangan.output();
system("PAUSE");
return EXIT_SUCCESS;
}

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 komentar:

Posting Komentar