If your teacher taught you this, (s)he should be fired.
void main
clrscr
And use cin.get() instead of getch(); It's a non-standard function.
Also update your Turbo compiler to something from the last 10 years by downloading code::blocks (free)
Now for your question: There's no way to know what the ouput it. It is completely undefined behaviour as you've wrote it. My rule of thumb: Never use more then 1 increment operator in a statement.
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
>can u plz explain that when is the order of precedense will be right to left?
Are you deaf?
Look at the post #2 and try to accept that what ever niek has said is actually true.
Your program is suffering from undefined behaviour . All that means to you is that 'anything' can happen when you run the program.
There is a FAQ on Bjarne Stroustrup's FAQs( http://www.research.att.com/~bs/bs_faq2.html#evaluation-order ) and also on Marshal Cline's FAQs( http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 )
Try to read and understand them.
In simple term:
1. Sequence point is a point of time while executing your code at which all the variables have defined values.
2. Any operation done which alter the value of a variable more than once in between only a pair of consecutive sequence point leads to undefined behaviour .
No doubt, there are teachers who put forward these kinds of question trying to show off how tricky their questions are . Actually, all they are doing is teaching their student to depend on studying implementation specific behaviour.
Regarding, the use of void main, conio.h and clrscr(), read http://siddhant3s.elementfx.com/
siddhant3s
Practically a Posting Shark
816 posts since Oct 2007
Reputation Points: 1,486
Solved Threads: 140
Take a look at this thread - Everything you wanted to know about undefined behaviour (but were afraid to ask).
SUMMARY (posted by salem) :
This is a catalogue of some experiments on just two aspects of undefined behaviour.
This was inspired by yet another long bout of explanation in a recent thread, so I thought it was time to dust off a bunch of compilers, and compare.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241