I’m trying to make a FOR loop in c with specific i values for example i=2,6,8,12,16,20,22,26,34.. I just don’t know how to specify increments as they are not equal. This code is not good for me.
for (i=2,i<=30,i++) {
}
Maybe with specified array of values in i and then run for loop with reference to that array?
Any help?
Your
for-loop syntax needs to be fixed.The first option is to use a custom function:
where
foois a function which takes the current value ofiand returns the next value. You will need to come up with a proper definition offooyourself.The other approach can be to put all these values in an array and use the array as indices: