SHARE
TWEET

Untitled

a guest Jun 16th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.     int a[10];
  9.     int banyak;
  10.     bool prima;
  11.  
  12.   cout<<"Masukkan banyaknya piring: ";
  13.   cin>>banyak;
  14.  
  15.   for (int i=0; i<banyak; i++) {
  16.     cout<<"Piring ke-"<<i+1<<" : ";
  17.     cin>>a[i];
  18.   }
  19.  cout<<endl;
  20.  cout<<"Piring yang sudah masuk: ";
  21.  for (int i=0; i<banyak; i++)
  22.  cout<<a[i];
  23.  
  24. cout<<endl;
  25.  
  26.  for (int i=0; i<banyak; i++) {
  27.         prima=true;
  28.         for (int j=2; j<=a[i]/2; j++) {
  29.             if (a[i]%j==0) {
  30.                 prima=false;
  31.                 break;
  32.         }
  33.  }
  34.             if (prima)
  35.             cout<<a[i]<<" bilangan prima"<<endl;
  36.             else
  37.             cout<<a[i]<<" bukan prima"<<endl;
  38.  
  39.  }
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top