Algoritma :
Deskripsi
a,b : integer
nilai : integer
Deklarasi
for i <= 1 to b do
nilai = nilai + a
if ( nilai % b = 0 )
then
write(nilai)
endif
endfor
Berikut programnya :
#include <iostream.h>
#include <conio.h>
void main()
{
int a,b,nilai;
nilai=0;
cout<<"Masukkan bilangan pertama : "; cin>>a;
cout<<"Masukkan bilangan kedua : "; cin>>b;
for(int x=1;x<=b;x++)
{
nilai=nilai+a;
if(nilai % b==0)
{
cout<<"KPK antara "<<a<<" dan "<<b<<" Adalah "<<nilai;
break;
}
}
getch();
}
Explanation:
The program above is used to find the Commission of the input integer. In this program using for loop and the selection if the process by which the value of% b = 0. KPK resulting output from the input two integers.
The program above is used to find the Commission of the input integer. In this program using for loop and the selection if the process by which the value of% b = 0. KPK resulting output from the input two integers.
0 komentar:
Posting Komentar