i=i++ + ++i; j++ + ++j; k=k++ + k++ + ++k; All these Statements have compiler Dependent Output, As they violet sequence point rule ( here value of a variable is modified two or more times between two successive sequence points.) Standard does not specify the exact order of execution of these type of statements.
On Sat, Jan 21, 2012 at 5:12 PM, Kailash Bagaria <[email protected]> wrote: > > Please explain the output of the following program.... > > #include <iostream> > using namespace std; > int main() > { > int i=5; > i=i++ + ++i; > cout<<i<<endl; > > int j=5; > cout<<j++ + ++j<<endl; > > int k=5; > k=k++ + k++ + ++k; > cout<<k<<endl; > > system("pause"); > return 0; > } > -- > > -- > > ‘Kailash Bagaria’ > B-tech 3rd year > Computer Science & Engineering > Indian Institute of Technology, Roorkee > Roorkee, India (247667) > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
