IJUL'S BLOG

Fungsi Untuk Bil. Prima

catatan kuliahq:
ni source code nya bro:

#include <iostream.h> //untuk mengenali fungsi cin & cout
#include <conio.h> //untuk mengenali fungsi getche
int n,m;
void prima();
void jumlah();
void main()
{
cout<<"PROGRAM UNTUK MENENTUKAN DERET BILANGAN PRIMA"<<endl<<endl;
cout<<"Batas dari Deret Bilangan Prima X: ";
cin>>n;
cout<<"Batas dari Deret Bilangan Prima y: ";
cin>>m;
cout<<endl;
cout<<"Deret Bilangan Prima dari "<<n<<" sampai "<<m<<" adalah: "<<endl<<endl;
prima();
jumlah();
}
void prima()
{
int x, cek, i;
for (x = n+1; x<m; x++)
{
cek = 0;
for (i = 2; i < x; i++)
{
if (x % i == 0)
cek = 1;
}
if (cek == 0)
{
cout<<x<<", ";
}
}
{
cout<<endl<<endl<<endl;
}
getch();
}
void jumlah()
{
int x, cek, i;
int Jml=0;
for (x = n+1; x<m; x++)
{
cek = 0;
for (i = 2; i < x; i++)
{
if (x % i == 0)
{
cek = 1;
}
}
if (cek == 0)
{
Jml=Jml+x;
}
}cout<<"hasil jumlah = "<<Jml;
}

 

0 komentar:

Posting Komentar

Powered By Blogger
Diberdayakan oleh Blogger.

Entri Populer

PENGUNJUNG

Buku Tamu

About Me

Foto Saya
Ijal Ferdi
there is no something special about me,,, but this blog is so special for me......
View my complete profile

Total Tayangan Halaman

Followers