430 views
2 votes
2 votes
#include <stdio.h>
 
int main(void) {
	static int a[10];
	int x=0;
	a[x]=++x;
	printf("%d %d %d",a[0],a[1],a[2]);
	return 0;
}

my doubt here is [ ] has high precedence over ++ which in turn has precedence over =, so i think it a[x] = ++x; is evaluated in 3 phase like,

phase1: a[x] -> (a+x)* -> (a+0)* -> a*

phase2: ++x -> x=1

phase3: a*=1 or a[0]=1

so finally answer should be 1 0 0, but it is giving 0 1 0 as output.

Please log in or register to answer this question.

Related questions

1 votes
1 votes
1 answer
2
jugnu1337 asked May 10, 2022
290 views
SOURCE NAME::: UNDERSTANDING POINTER IN C (BOOK) BY YASHWANT KANETKARmy answer is C am i right?
1 votes
1 votes
0 answers
3
aakash pandey asked Apr 30, 2022
292 views
We use character array to declare string in C. So, if I declare an array likecharacter ch[ ] = {‘a’,’k’,’a’,’/o’};and try printing ch[3] like :printf(“%...
0 votes
0 votes
0 answers
4
Anirudh Kaushal asked Apr 6, 2022
202 views
#include<stdio.h struct marks { int p:3; int c:3; int m:2; }; void main() { struct marks s = {2, -6, 5}; printf("%d %d %d", s.p, s.c, s.m); }What does p:3 means here ?