- Back to Home »
- Program C++ Menentukan Bilangan Prima
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int bil, i, jum;
cout<<"Masukkan Bilangan\t: ";scanf("%i",&bil);
jum=0;
for(i=1;i<=bil;i++)
{
if(bil%i==0)
{
jum++;
}
}
if(jum==2){
cout<<"Bilangan Prima", bil;
}
else
cout<<"Bukan Bilangan Prima", bil;
cout<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}