Program Mengeluarkan bilangan Prima


#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int bil, i, j, j1, j2, maksimum;
    char ulang;
    do
    {
    cout << "masukkan nilai maksimum: "; cin >>maksimum;
    cout<<endl;
for(bil=2; bil<=maksimum; bil++)
{
for(i=2;i<=bil/2;i++)
{
j=bil%i;
j2=bil%3;
}
if((j!=0)&&(j2!=0)) cout<<bil<<"\t";
}

    cout<<endl;  
    cout <<"======================================" << endl;
    cout<<endl;
    cout << "Ulangi program ramalan [y] atau [t] ?? ";cin >>ulang;
    system ("cls");
}
    while (ulang=='y'|| ulang=='Y');
    cout<<endl<<endl;
   
    // system("PAUSE");
    return EXIT_SUCCESS;
}

Gambar hasil program


Komentar

Postingan Populer