#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int i,a,b,r,kpk;
int p;
kpk=0;
cout<<"1. Menentukan KPK"<<endl;
cout<<"2. Menentukan FPB"<<endl;
cout<<"3. EXIT"<<endl;
cout<<"Masukkan pilihan anda : ";
cin>>p;
switch (p)
{
case 1:
cout<<"\nMencari KPK"<<endl;
cout<<"Masukkan Bilangan Pertama : ";
cin>>a;
cout<<"Masukkan Bilangan Kedua : ";
cin>>b;
cout<<endl;
for(i=1;i<=b;i++)
{
kpk=kpk+a;
if(kpk % b==0)
{
cout<<"\nKPK : "<<kpk<<endl;
break;
case 2:
cout<<"\nMencari FPB"<<endl;
cout << "Masukkan Bilangan Pertama : ";
cin >>a;
cout << "Masukan Bilangan Kedua : " ;
cin >>b;
r = a%b;
while (r!=0)
{
a = b;
b = r;
r = a%b;
}
cout<<"\nFPB : "<<b<<endl;
break;
case 3:
cout<<"EXIT Now !!!"<<endl;
break;
default:
cout<<"Error !!!"<<endl;
}
}
system("PAUSE");
return EXIT_SUCCESS; }
}
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int i,a,b,r,kpk;
int p;
kpk=0;
cout<<"1. Menentukan KPK"<<endl;
cout<<"2. Menentukan FPB"<<endl;
cout<<"3. EXIT"<<endl;
cout<<"Masukkan pilihan anda : ";
cin>>p;
switch (p)
{
case 1:
cout<<"\nMencari KPK"<<endl;
cout<<"Masukkan Bilangan Pertama : ";
cin>>a;
cout<<"Masukkan Bilangan Kedua : ";
cin>>b;
cout<<endl;
for(i=1;i<=b;i++)
{
kpk=kpk+a;
if(kpk % b==0)
{
cout<<"\nKPK : "<<kpk<<endl;
break;
case 2:
cout<<"\nMencari FPB"<<endl;
cout << "Masukkan Bilangan Pertama : ";
cin >>a;
cout << "Masukan Bilangan Kedua : " ;
cin >>b;
r = a%b;
while (r!=0)
{
a = b;
b = r;
r = a%b;
}
cout<<"\nFPB : "<<b<<endl;
break;
case 3:
cout<<"EXIT Now !!!"<<endl;
break;
default:
cout<<"Error !!!"<<endl;
}
}
system("PAUSE");
return EXIT_SUCCESS; }
}
itu dia script nya ada juga dapat mendownload filenya di link di bawah ini.
.......semoga bermaanfaat untuk semuanya.....
link download:
download