473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

c increment & decrement

sir,

I am a new user of c language .plz. explain me the what will be the output of this code and why?

int i=1;
{
printf("%d%d%d%d",++i,i++,--i,i--);
}
actually I understand ++i or i++ but when using with 2 or 4 variables i am being confused.
plz. explain in details the output of this program.
Aug 16 '10 #1
2 2176
newb16
687 512MB
It's undefined because several increments/decrements on i variable happens before the next sequence point. The generated code may change the value of 'i' after calculating all parameters' values, resulting in output 2101, or change it after each parameter value is calculated (2222, if they are evaluated left to right)
Aug 16 '10 #2
donbock
2,426 Expert 2GB
Wasn't this question already answered yesterday in your other post?
Aug 16 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Mark Turney | last post by:
I was reading "Practical C++ Programming" yesterday, and it mentioned that the order of execution for post-increment and post-decrement operators was ambiguous. I had previously learned that a...
5
by: arnuld | last post by:
it compiles without any trouble but produces "Segmentation Fault" when i try to run it. since i am at chapter 2 so my knowledge of arrays is limited to chapter 1: -------------------------...
56
by: Zytan | last post by:
Obviously you can't just use a simple for loop, since you may skip over elements. You could modify the loop counter each time an element is deleted. But, the loop ending condition must be...
3
by: shivapadma | last post by:
i want clear explanation of increment and decrement operators in c. can any body help in solving the following expression a=10 c=++a + ++a when i am executing this code ,the answer is c=24...
3
by: suman das | last post by:
slove this problem include<stdio.h> include<conio.h> void main() { int i=1; printf("%d",i++*++i); getch(); }
6
by: Kevin Walzer | last post by:
This code: #include <stdio.h> int main(void) { int n1, n2; //two integers n1 = 1; n2 = 1;
13
by: jehugaleahsa | last post by:
Hello: In C++, you had to distinguish between post and pre increments when overloading. Could someone give me a short demonstration of how to write these? I get the impression that are...
35
by: mdh | last post by:
Hi All, this little nonsense function is an attempt to understand function pointers. /*********/ #include <stdio.h> void p(int);
3
by: subramanian100in | last post by:
Consider the code fragment: vector<intcontainer; container.insert(container.begin(), 10); int& ref = *--container.end(); From this, it looks like we can apply prefix decrement operator to...
3
by: Stang1 | last post by:
The following statement: line_buf = ' '; is equivalent to: line_buf = ' '; line_len++;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.