Monday, October 31, 2016

Program Menentukan Bilangan Prima dengan C++

Source Code :


#include <iostream>

using namespace std;

int main(){
int bil,b=0,hasil=0;
cout<<"Mengecek Bilangan Prima\n\n";
cout<<"Masukan Bilangan = ";
cin>>bil;
for (int a = 1;a <= bil;a++){
hasil = bil % a;
if (hasil == 0){
b++;
}
}
if (b==2){
cout<<endl<<bil<<" Adalah Bilangan Prima"<<endl<<endl;
}
else {
cout<<endl<<bil<<" Bukan Bilangan Prima"<<endl<<endl;
}
system("pause");
}



--------------------------------------------------------------------------------------------------------------------------
Hasiil Program :









Semoga Bermanfaat :):):)

No comments:

Post a Comment