Re: Coding in C: help with if statements
Holy cow, it worked beautifully! I set I to 100000 and manually set j<=8 in the while loop. It's working perfectly, now. Thank you so much! So, just to understand what I should do in the future if something similar happens: I set the value of my "define" variable equal to the maximum time I can accomplish one loop in my program?
Oh, I was actually aware of that, this is why the first action I do in my "while" loop is j++, so j begins at 1. Although, you're right: if I set my j++ action at the end of the while loop, I can start counting at 0. My while condition became j<=7.
thank you soooooooo much.
Here's the final code:
Holy cow, it worked beautifully! I set I to 100000 and manually set j<=8 in the while loop. It's working perfectly, now. Thank you so much! So, just to understand what I should do in the future if something similar happens: I set the value of my "define" variable equal to the maximum time I can accomplish one loop in my program?
Also, arrays are zero indexed. So in the following lines:
N[1]=3; /* I manually assignate a value for each N */
N[2]=10;
N[3]=30;
N[4]=100;
N[5]=300;
N[6]=1000;
N[7]=3000;
N[8]=10000;
you should start counting from 0 and not 1. The element N[8] is actually the 9th element and is not in the space you have allocated for the array.
N[1]=3; /* I manually assignate a value for each N */
N[2]=10;
N[3]=30;
N[4]=100;
N[5]=300;
N[6]=1000;
N[7]=3000;
N[8]=10000;
you should start counting from 0 and not 1. The element N[8] is actually the 9th element and is not in the space you have allocated for the array.
thank you soooooooo much.
Here's the final code:

Comment