Click here to Skip to main content
15,943,210 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
int[] a={ 15,51,2,12,280,5,43,30,33};

can u please tell me code to take only the numbers which is multiples of 3 from above set of numbers.
phil.o 7-Apr-15 6:48am    
What have you tried?

1 solution

public void GetMultipleOfNumber(int[] Array, int Number)

You can do this on your own, can't you?
Its easy, the method head is given.
You just need to iterate (for-slope) through your array.
Then do a modulo on that! (Array[i]%Number).
If the modulo returns 0 it's good (E.g. 15%3 = 0)
Then you can do with the result what you want.

Finished. Basic stuff. Homework...
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900