as sad divides the element in the array at index i by k you want it the other way roundCode: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 roundCode:if (myarray[i] %2 == 0)// says if the elemen in my array at index i is devisable by k { // do stuff }
yep it is... that's why you aren't getting the output you want because it is dividing the element not the index
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
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
i is being used as an index
so divide i by k not the element
if(i%k == 0)
This doesn't give good result
whats wrong with it
This...![]()
Result should be here 4. Right?
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
No, i don't know... help me
printf("%d",myarray[i]) like you had in the if statement