Advertisement
satriafu5710

Ganjil dan Genap Data Array Statis c++

Dec 8th, 2020
4,020
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6.     int angka [] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  7.  
  8.     cout << "\t Menentukan Ganjil & Genap Data Array \n";
  9.  
  10.    cout << "\n Genap  : ";
  11.  
  12.    for(int i = 0; i < 10; i++){
  13.  
  14.        if(angka[i] % 2 == 0){
  15.  
  16.            cout << angka[i] << ", ";
  17.        }
  18.    }
  19.  
  20.     cout << "\n Ganjil : ";
  21.  
  22.     for(int j = 0; j < 10; j++){
  23.  
  24.         if (angka[j] % 2 != 0){
  25.  
  26.             cout << angka[j] << ", ";
  27.         }
  28.        
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement