ok, so i have a simple code below but i need an array function that calculates which elements are divisible by 5 and then its passes the results to the main function and outputs them, any help with code on how to do it will be appreciated?
basically the above code and the one i want do the same thing. but i need help on this one.
the array function should look something like this: calcdiv(int[a], int size];
thanks in advance

#include <iostream>

using namespace std;

int main() {
  int a[5] = {5, 10, 13, 20 , 39};
  int result[5] = {-1, -1, -1, -1, -1};
  int count = 0;

  for(int i = 0; i < 5; i++) {
    if((a[i] % 5) == 0) {
      result[count] = a[i];
      count++;
    }
  }

  for(int i = 0; result[i] != -1 && i < 5; i++) {
    cout << result[i] << ' ';
  }

  return 0;
}

This is not a code snippet. This is a help question. Read the Rules before posting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.