PROGRAM PeriksaBilPrima
DEKLARASI
N,i : integer
Bilangan: string
ALGORITMA
read (N)
for (i=2; i<=N-1; i++)
if (N mod i ==0)
Bilangan<-'Bukan Prima'
write (N, Bilangan)
endif
endfor
CODING
#include<iostream>
#include<math.h>
using namespace std;
int main() {
int N;
string Bilangan;
cout<<"PROGRAM PERIKSA BILANGAN PRIMA ATAU TIDAK"<<endl;
cout<<"Masukan N="; cin>> N;
{Bilangan="Prima";}
for (i=2; i<=N-1; i++)
if (N%i==0)
{Bilangan="Bukan Prima";}
cout<<""<<endl;
cout<<N<<""<<Bilangan<<endl;
system("PAUSE");
}
Download program disini https://drive.google.com/open?id=1WaEqGTY36bS9VDWGyrwWIq6tm-ckl2y8
No comments:
Post a Comment