Online C++ Compiler

#include <bits/stdc++.h> using namespace std; int divisible_k(int arr[], int size, int k) { int count = 0; for(int i = 0; i<size; i++) { if(arr[i]%k==0) { count++; } } return count; } int main() { int arr[] = {4, 2, 6, 1, 3, 8, 10, 9}; int k = 2; int size = sizeof(arr) / sizeof(arr[0]); cout<<"Count the number of elements in an array which are divisible by "<<k<<" are: "<<divisible_k(arr, size, k); return 0; }