1. Code:
``` if (myarray[i] %2 == 0)// says if the elemen in my array at index i is devisable by k
{
// do stuff
}```
as sad divides the element in the array at index i by k you want it the other way round

2. Originally Posted by cooper1200
Code:
`myarray[i] % 2`
divides he element
Code:
` if(brojevi[i]%k == 0)`
Isn't this the same?

3. yep it is... that's why you aren't getting the output you want because it is dividing the element not the index

4. if you enetered the numbers 1 3 5 9 7 8 and 2 for k you would get the output 5 as in index 5 where you said you want the output 1, 5 and 7 as in the elements at location 0, 2 and 4

5. Originally Posted by cooper1200
if you enetered the numbers 1 3 5 9 7 8 and 2 for k you would get the output 5 as in index 5 where you said you want the output 1, 5 and 7 as in the elements at location 0, 2 and 4
So, how to fix this?

6. ask yourself what is the variable i being used for is it to index the array
what does printf("%d", myarray[i]) give is it the value stored at index i or is it the index if its the value how do i divide the index by k

7. Originally Posted by cooper1200
ask yourself what is the variable i being used for is it to index the array
what does printf("%d", myarray[i]) give is it the value stored at index i or is it the index if its the value how do i divide the index by k
Feel free to shoot me, or show me complete code

8. i is being used as an index
so divide i by k not the element

9. if(i%k == 0)

This doesn't give good result

10. whats wrong with it

11. This...

12. Result should be here 4. Right?

13. so why are you still printing out the index not the element you know how to address the element you did it for your if statement

14. No, i don't know... help me

15. printf("%d",myarray[i]) like you had in the if statement