fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void greaterNumbers(const int[], int, int);
  5.  
  6. int main()
  7. {
  8. const int ARRAY_SIZE = 30;
  9. int numbers_array[ARRAY_SIZE] = {1, 2, 3, 4, 5,
  10. 6, 7, 8, 9, 10,
  11. 11, 12, 13, 14, 15,
  12. 16, 17, 18, 19, 20,
  13. 21, 22, 23, 24, 25,
  14. 26, 27, 28, 29, 30};
  15. int n = 20;
  16.  
  17. cout << "All numbers greater that " << n << " are: ";
  18. greaterNumbers(numbers_array, ARRAY_SIZE, n);
  19. cout << endl;
  20.  
  21. return 0;
  22. } // END int main()
  23.  
  24. void greaterNumbers(const int array[], int ARRAY_SIZE, int n)
  25. {
  26. for (int i = 0; i < ARRAY_SIZE; i++)
  27. {
  28. if (array[i] > n)
  29. {
  30. if(i == ARRAY_SIZE - 1)
  31. cout << array[i];
  32. else
  33. cout << array[i] << ", ";
  34.  
  35. }
  36.  
  37. }
  38.  
  39. }
Success #stdin #stdout 0.01s 5268KB
stdin
Standard input is empty
stdout
All numbers greater that 20 are: 21, 22, 23, 24, 25, 26, 27, 28, 29, 30