Minggu, 17 Agustus 2014

PROGRAM DERET BILANGAN PRIMA

By Lia Saimin   Posted at  18.25   pemograman No comments


#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    int i, j, prima;
    cout << "Nama : Angelia Saimin " << endl
         << "NIM  : 13013061" << endl
         << "Kelas: TIR 2.1" << endl << endl;

    cout << "=====================================" << endl
         << " PROGRAM DERET BILANGAN PRIMA" << endl
         << "=====================================" << endl <<endl;

    cout << "Bilangan Prima 1-100" << endl;
    for (i=0;i<=100;i++)
    {
        prima=false;
        if (i==2)
            prima=true;
        else
            {
                for (j=2;j<i;j++)
                {
                    if (i % j==0)
                    {
                        prima=false;
                        break;
                    }
                    else
                        prima=true;
                }
            }
        if (prima)
        {
            cout << i << " , ";

        }

    }
    cout << endl << endl << "Bilangan Prima 100-200" << endl;
    for (i=100;i<=200;i++)
    {
        prima=false;
        if (i==2)
            prima=true;
        else
            {
                for (j=2;j<i;j++)
                {
                    if (i % j==0)
                    {
                        prima=false;
                        break;
                    }
                    else
                        prima=true;
                }
            }
        if (prima)
        {
            cout << i << " , ";

        }

    }

    cout << endl << endl << "angelia-saimin.blogspot.com" << endl;
   getch ();

}

About the Author

Nulla sagittis convallis arcu. Sed sed nunc. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.
View all posts by: BT9

0 komentar:

Back to top ↑
Connect with Us

What they says

© 2013 Angelia Saimin. WP Mythemeshop Converted by Bloggertheme9
Blogger templates. Proudly Powered by Blogger.