• closed by
1,257 views
1 1 vote
closed with the note: It has sequence point problem.
#include<stdio.h>
void main(){
int i=11;
printf("%d \n", i++|++i);
printf("%d",i);
}

Output is: 15
13

I understand how 13 came but I don't get how 15 came. And why there is no sequence point problem in this?

1 Answer

1 1 vote

bro take this line 
printf("%d \n", i++|++i); this is nothing but 

11 = 1011
12 = 1100

11 || 12  = (1011 | 1100) = BitwiseOR(1011,1100) = (1111)2 = (15)10

Position:
Show:

Related questions

1 1 vote
1 1 answer
282
282 views
khanshahima4 asked Sep 24
282 views
1. If precedence tells me which operator has priority, and associativity tells me how to handle operators at the same level, then why do I need a separate concept called ...
14 14 votes
1 1 answer
1.3k
1.3k views
GO Classes asked Jul 2
1,348 views
Assume:$\texttt{short = 2 bytes}$, $\texttt{int = 4 bytes}$, $\texttt{char = 1 byte}$$\texttt{int}$ needs $4$-byte alignment and the final structure size is rounded to a ...
18 18 votes
2 2 answers
752
752 views
GO Classes asked Jul 2
752 views
Assume:struct Student { double gpa; }; struct Student alice; struct Student *sptr = &alice;Which of the following correctly assigns $\texttt{4.0}$ to $\texttt{alice.gpa}$...
10 10 votes
1 1 answer
560
560 views
GO Classes asked Jul 2
560 views
Consider the following code idea from the source:typedef struct { double x, y; } Point; void reset(Point p) { p.x = p.y = 0; } int main() { Point a = {12.0, 42.0}; Point ...