Subscribe:

Jumat, 19 April 2013

program mencari KPK C++


/*
mencari KPK
misal input
a = 4 , b = 6
kpknya = 12
*/

#include
#include

using namespace std;

int main(int argc, char *argv[])
{
    int a, b, angka, data=0;
    cout<<"a = ";
    cin>>a;
    cout<<"b = ";
    cin>>b;
    angka=a;
    while(data==0)
    {
    if((angka%a==0)&&(angka%b==0))
{
    cout<<"KPK = "<    data=1;
}
    angka++;
}
cout<    system ("PAUSE");
    return EXIT_SUCCESS;
}


0 komentar: