Ask your own question, for FREE!
Computer Science 8 Online
OpenStudy (anonymous):

C code. If I want to display a set of numbers (i.e. calculating numbers with increments). For example: if i want to start with a minimum 100 and increment of 10 every time to a maximum of 200. What is the code or formula is should use?

OpenStudy (anonymous):

for( i = 100; i < 201; i += 10) { < do something exciting with i > } should work

OpenStudy (espex):

If you are only interested in every 10th value for i, then yes, the code you have should work. You could also use a counter of 10 and multiply your variable inside like this: int k = 100; for (i = 0; i <= 10 ; i++){ printf("the value of k is: %d", k); k = k*10-1; } Ultimately it depends on what you want to accomplish.

OpenStudy (anonymous):

unnfortunately, k*10 - 1 evaluates to 999, then 9989, then... perhaps not what was desired. The idea is right, but use k = k + 10

OpenStudy (espex):

Yes, my mind was elsewhere, still thinking that k was incremented, as i is, once each loop and so you would need to decrement it.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!