# What is this output?

• 12-12-2008
xbusterx
What is this output?
a= 5 , b = 6

a = (b++) + 3;

c = 2*a + (++b);

d = 2 * (++c) - (a++);

What are the values?
• 12-12-2008
laserlight
Try to reason out the answers then put those statements into a program and see the output for yourself.
• 12-12-2008
xbusterx
Quote:

Originally Posted by laserlight
Try to reason out the answers then put those statements into a program and see the output for yourself.

My program isn't working right now and I don't know what to do. What is the output can someone help me?
• 12-12-2008
laserlight
Quote:

Originally Posted by xbusterx
My program isn't working right now and I don't know what to do.

Fix it. What is your current program?
• 12-12-2008
jwenting
Quote:

Originally Posted by xbusterx
My program isn't working right now and I don't know what to do. What is the output can someone help me?

what do you think it should be?
Tell us and we may tell you whether you're right...
• 12-12-2008
xbusterx
Quote:

Originally Posted by xbusterx
a= 5 , b = 6

a = (b++) + 3;

c = 2*a + (++b);

d = 2 * (++c) - (a++);

What are the values?

a = 10, c = 27 ?, dunno what d is
• 12-12-2008
matsp
Can you produce the steps that you come to that conclusion from? [hint: I think it's wrong, I think I know WHERE you are going wrong, but it's much easier to explain what you are doing wrong if you actually show the individual steps of your calculation].

--
mats
• 12-12-2008
EVOEx
Quote:

Originally Posted by xbusterx
a = 10, c = 27 ?, dunno what d is

Can you tell me what you think the difference is between:
Code:

b++;
++b;

Because it seems you mix those two up. I think your answers would be correct if you mix those up ;).
• 12-12-2008
Akkernight
Why do you declare a = 5, then later a = (b++) + 3 o.O?
• 12-12-2008
CornedBee
Quote:

Originally Posted by Akkernight
Why do you declare a = 5, then later a = (b++) + 3 o.O?

I don't think the input is under his control.