Forums Register Login

value of x?

+Pie Number of slices to send: Send
I want to know that how come value of x in the output of the following program is not -1 but 0.




OUTPUT:

02
14
26
48

[Edit - added code tags - see UseCodeTags for details]

1
+Pie Number of slices to send: Send
Hi Supriya. Welcome to The Ranch!

Why do you think it should be -1? Where do you think it gets set to -1.

What I'd suggest is drawing up a little table like this:

Step through the code by hand, writing down the values of x and y when they change, and the output at each print statement. Try that, and if you still don't see why that's the output let us know.
1
+Pie Number of slices to send: Send
Hi Supriya.

Your code has part witch is never reached.


is the same as


Now your code looks more clearly, so maybe it will be easier to step through your code by hand as Matthew wrote.
+Pie Number of slices to send: Send
 

Piotr Majcher wrote:Hi Supriya.

Your code has part witch is never reached.



Please don't just hand over the answers. We want to encourage the OP to solve his own problem, with a nudge in the right direction here or there as needed. Thanks!
+Pie Number of slices to send: Send
 

Jeff Verdegan wrote:

Piotr Majcher wrote:Hi Supriya.

Your code has part witch is never reached.



Please don't just hand over the answers. We want to encourage the OP to solve his own problem, with a nudge in the right direction here or there as needed. Thanks!


No problemo I'm newbie here, and this is good advice for me to be good forum user in the future. Thanks.
+Pie Number of slices to send: Send
Thank You.Now i understood.
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1095 times.
Similar Threads
Head first Java - Chapter 4 Pool Puzzle p.91
Doubt from Whizlab Question
++ again
Static?
Bowled over by a simple code
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:09:46.