edited by
6,222 views
9 votes
9 votes

The for loop

for (i=0; i<10; ++i)
printf("%d", i&1);

prints

  1. 0101010101
  2. 0111111111
  3. 0000000000
  4. 1111111111
edited by

5 Answers

1 votes
1 votes
i&1 is basically checking whether i is even or odd.If it's even it'll return 1 else 0. Based on this I think output should be A.
Answer:

Related questions

10 votes
10 votes
4 answers
1
go_editor asked Jun 21, 2016
9,493 views
The output of the following program ismain() { static int x[] = {1,2,3,4,5,6,7,8} int i; for (i=2; i<6; ++i) x[x[i]]=x[i]; for (i=0; i<8; ++i) printf("%d", x[i]); }1 2 3 ...
8 votes
8 votes
2 answers
2
go_editor asked Jun 21, 2016
7,721 views
Consider the following program fragmenti=6720; j=4; while (i%j)==0 { i=i/j; j=j+1; }On termination j will have the value4896720
7 votes
7 votes
3 answers
3
go_editor asked Jun 21, 2016
6,731 views
The following programmain() { inc(); inc(); inc(); } inc() { static int x; printf("%d", ++x); }prints 012prints 123prints 3 consecutive, but unpredictable numbersprints 1...
13 votes
13 votes
8 answers
4
milankamilya asked Jun 14, 2016
8,617 views
If n has 3, then the statement a[++n]=n++;assigns 3 to a[5]assigns 4 to a[5]assigns 4 to a[4]what is assigned is compiler dependent