How to find odd and even numbers in 5x5 array using func

Hello guys... how to return odd and even numbers in 5x5 array and put the odd number in array and even numbers in another array using func
This is the array
int n[5][5] = { { 1,2,3,4,5}
,{6,7,8,9,10}
,{11,12, 13,14,15}
,{16,17,18,19,20}
,{21,22,23,24,25} };
if number %2 == 0 its even else odd.

loop over the data and return the values in a vector or something.


Thank you @jonnin can you give me the code please?
We are not a code writing service. If you want to learn programming, make a plan and start writing some code and if you get stuck you can get help.

https://www.tutorialspoint.com/cplusplus/cpp_multi_dimensional_arrays.htm
@Thomas Thank you! I don't want you to write a code to me... I'm just ask for the method to write this code...note :I'm an engineer student 😉
@Dani, you are very inconsistent.
You have just written (to @Jonnin):
can you give me the code please?

and (to @Thomas1965):
I don't want you to write a code to me


I note:
I'm an engineer student

Then I sincerely hope that in both this thread and your other current one you will be able to:
(a) express your problem more clearly;
(b) make an effort to provide some initial start code of your own.
Did you know that "engineer" came from the same root as "ingenuity"?
goodness. Ill do it but you get what you get with me lol. I take the direct approach and don't believe in 2d arrays. Do show some effort going forward, though. Most of us work in the industry. Most of us have had to deal with new hires that cheated their way thru school. Most of those people did not keep their jobs long.

1
2
3
4
5
6
7
8
vector<int> o;
vector<int> e;
int *ip = n[0];  //convert 2d mess array to 1d
for(int i = 0; i< 25; i++)  //iterate over 1d version
   if(ip[i]%2 ==0)
     e.push_back(ip[i])  //load the even vector
   else
     o.push_back(ip[i]) //load the odd vector 

Last edited on
Topic archived. No new replies allowed.