Menampilkan bilangan prima

halo, gimana kabar kalian semua?
semoga baik2 saja ya.
kali ini aku akan membagikan source code untuk menampilkan bilangan prima.
langsung saja..
cekibroottt



#include <iostream>
using namespace std;
main(){
 int x, cek, i , z;

 cout<<"PROGRAM MENAMPILKAN BILANGAN PRIMA DARI 1 SAMPAI 100"<<endl<<endl;
 cout<<"Masukkan nilai  : ";
 cin>>z;
 for (x = 2; x<=z; x++){
    cek = 0;
  for (i = 2; i < x; i++){
       if (x % i == 0){
          cek = 1;
         }
      }
      
      if (cek == 0){
       cout<<x<<"  ";
      }
   }


return 0;

}

Share on Google Plus

About Luthfi

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 komentar:

Posting Komentar