[wplug] about basic programming
Bryon Gill
bgtrio at yahoo.com
Fri Mar 4 16:02:21 EST 2005
Actually, it is incremented to 40 after you print 39, then you check to see if
it's < 40 on the next run through, it's not so you don't print your line. You'd
be well served by <= rather than < in this case if you want to see the number
40, or by incrementing before you print.
On Fri, 4 Mar 2005, Tom Rhodes wrote:
> On Fri, 4 Mar 2005 14:03:13 -0500
> John Harrold <jmh17 at pitt.edu> wrote:
>
>> Sometime in March Juan Zuluaga assaulted the keyboard and produced:
>>
>
> [SNIP]: Discussion on books.
>
> Perhaps someone with years of experiance in programming could
> tell me something. In the following program snip-it:
>
> #include <stdio.h>
>
> #define lastnum 40
>
> int main()
> {
>
> int num = 0;
>
> while ((num == 0) || (num < lastnum))
> {
> printf("Counting %d up\n", num);
> num++;
> }
> return 0;
> }
>
> num is only incremented to 39, one below 40. Thus far I have
> always considered it was because we stop at the number before
> the one we define. So I have always wrote as such. Yet, I
> have not found an explination in either of my two C books.
> Am I missing or not properly enterpreting a paragraph/sentence
> in my books?
>
> Yea, I'm sure everyone thinks I'm nuts now since I should know
> this, but, eh, whatever. *hand in the air* You don't know me!
> :)
>
>
More information about the wplug
mailing list