Advertisement
satriafu5710

Ganjil dan Genap Data Array Dinamis c++

Jan 17th, 2021
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6.     int array[5];
  7.    
  8.     cout << "\t Tentukan Ganjil / Genap \n\n";
  9.    
  10.     for(int i = 0; i < 5; i++){
  11.  
  12.         cout << " Nilai ke-" << i + 1 << " = ";
  13.         cin >> array[i];
  14.     }
  15.  
  16.     cout <<  endl;
  17.  
  18.     cout << " Bilangan Genap = ";
  19.    
  20.     for(int i = 0; i < 5; i++){
  21.  
  22.         if(array[i] % 2 == 0){
  23.  
  24.             cout << array[i] << " ";
  25.         }
  26.     }
  27.  
  28.     cout << endl;
  29.     cout << " Bilangan Ganji = ";
  30.  
  31.     for(int j = 0; j < 5; j++){
  32.  
  33.         if(array[j] % 2 != 0){
  34.  
  35.             cout << array[j] << " ";
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement