im having a difficult time figuring out my last two functions.

first one which is the
int divelement(int a[], int size);
this function is suppose to find and print the elements of my array that are only divisible by 5, so the answer will be like 10,15,90, and 95. i need help figuring out the algorithm

for my second one
int search(int a[], int size);
the user enters a number, and if the number is in the array it outputs "the number you enter does exist" and if it doesnt it outputs "the number you enter does not exist"

any help will be appreciated. or at least anyway how to get this started. thanks

#include <iostream>
#include <cmath>
using namespace std;

void printArray(int a[], int size);
void reverse(int a[], int size);
int average(int a[], int size);
int min( int a[], int size);
int divelement(int a[], int size);
int search(int a[], int size);

int main()
  const int size = 10;
  int small,a[] = {10, 15, 27, 89, 90, 95, 27, 13, 99, 33};
  small = a[0];
  int number;

  cout << "The original array is: ";
  cout << endl;

  cout << "The reversed array is: ";
  cout << endl;

  cout << "The average of the array is: "
       << average(a, size) << endl;

  min(a, size);
    cout << "The smallest element in the array is: "
         << small << endl;

    cout << "Enter a number between 1 and 99: " << endl;
    cin >> number;
    if(number == true)
      cout << "The number you entered exists";
      cout << "The number your entered does not exist in the array"
           << endl;

  return 0;

void printArray(int a[], int size)
  for (int i = 0; i < size; i++)
    cout << a[i] << " ";
void reverse(int a[],int size)
  int temp=0;
  for(int i=0;i<=(size)/2;i++)

int average(int a[], int size)
  int sum = 0;
  for (int i = 0; i < size; i++)
    sum += a[i

  return (sum / size);

int min(int a[], int size)
  int i;
  int small;
  for (i = 1; i < size; i++)
      if(small > a[i])
        small = a[i];
  return small;
int divelement(int a[], int size)


int search(int a[], int size[]


Here are some hints :

For the divelement function you need to see if a number is multiple
by 5? One way to do this is to use the mod operator. The mod operator returns the remainder. Here is an example on how to use it :

//returns true if a number if multiple of 7
bool isMultipleOfSeven(int num){
   return num % 7 == 0;

The main part is num % 7 == 0. For example say the input is 14.
Then 14 div 7 = 2 with 0 remainder. So if a remainer is 0 then 14 can
be evenly be divided by 7. Lets take a look at another example,
12 div 5 = 2 with 2 remainder. To see why look below :
5| 12
- 10
We see that, 5 goes into 12, two times, and we have 2 remainder. Thus
because the remainder is not 0, 12 is not a multiple of 5.

Now for the search function, your prototype is wrong, it should be this:

//Array[] is the array in which we will search in
//size is the maximum size of the array
// searchKey is the value we are looking for
int search(int Array[], int size, int searchKey);

Now for the search function all you have to do is loop over the whole
array, while checking if the searchKey is there.

This article has been dead for over six months. Start a new discussion instead.