Write a c++ function which takes two parameters: an array of ints and an int size of the array and prints every element greater than 5 to the screen. You may assume that the parameters passed to the function are valid. Your function must have the following signature:
void printSome(const int array[], int size);
#include <iostream> using namespace std; void printSome(const int array[], int size); int main() { int arr[] = {9, 1, 2, 7, 4, 10, 6}, size = 7; printSome(arr, size); return 0; } void printSome(const int array[], int size) { for (int i = 0; i < size; ++i) { // go through each element in array if (array[i] > 5) // if an element is larger than 5 cout << array[i] << endl; // then print it } }
Get Answers For Free
Most questions answered within 1 hours.