15,943,210 members
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.
Posted
Comments
phil.o 7-Apr-15 6:48am
What have you tried?

## Solution 1

Java
```public void GetMultipleOfNumber(int[] Array, int Number)
{
//Code
}```

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...

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

Top Experts
Last 24hrsThis month
 Pete O'Hanlon 40 RickZeeland 30 Member 16312379 10 Sandeep Mewara 5
 Pete O'Hanlon 905 OriginalGriff 800 Richard Deeming 715 merano99 345 Dave Kreskowiak 305

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