#include <bits/stdc++.h>
using namespace std;
int myfunc(int n, int m, int k, int arr[], int arr1[]) {
int x = 0, y = 0;
for (int i = 0; i < n; ++i) {
if (arr[i] > k) {
x += 1;
}
}
for (int i = 0; i < m; ++i) {
if (arr1[i] > k) {
y += 1;
}
}
return max(x, y); // why is this not working?
}
int main() {
int n, m, k;
int arr[n];
int arr1[m];
cin >> n >> m >> k;
cout << "first: \n";
for (int i = 0; i < n; ++i) {
cin >> arr[i];
}
cout << "2nd arr\n";
for (int i = 0; i < m; ++i) {
cin >> arr1[i];
}
myfunc(n, m, k, arr, arr1);
return 0;
}
In this code function is not returning any value but when I use cout<<max(x,y)
instead of return max(x,y)
, it's working fine. Can anyone explain me why is this happening?