Advertisement
avr39-ripe

arrRandEven

Jan 18th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     const int arrSize{ 10 };
  6.     int arr[arrSize]{};
  7.  
  8.     for (int i{ 0 }; i < arrSize; ++i)
  9.     {
  10.         arr[i] = rand() % 11;
  11.         if (arr[i] % 2 == 0)
  12.         {
  13.             std::cout << arr[i] << '\t' << i << '\n';
  14.         }
  15.     }
  16.  
  17.     std::cout << '\n';
  18.  
  19.     for (int i{ 0 }; i < arrSize; ++i)
  20.     {
  21.         std::cout << arr[i] << ' ';
  22.     }
  23.    
  24.     std::cout << '\n';
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement