Prerequisite for this question is Precedence and Associativity Rules and working principle of Ternaray Operator
Output depends upon the line k==1>0?i++:2;
1) k==1>0?i++:2; ===> By precedence and associativity rules, == operator having high priority than ?: operator
therefore the statement converted as ( ( k==1 ) > 0 ? i++ : 2 ) but note that output of this line is not assigned by any variable.
k==1 leads false therefore return 0, now ( ( 0 ) > 0 ? i++ : 2 ) the ternary operator checks 0>0, it leads false therefore returning 2 but not executes i++
therefore k=0 and i=10
2) k=1>0?i++:2; ===> By precedence and associativity rules, = operator having less priority than ?: operator
therefore the statement converted as ( k = ( 1 > 0 ? i++ : 2 ) ) but note that output of this line is assigned to variable k
the ternary operator checks 1>0, it leads true therefore executes ( i++ and return the value to k ) but not returning 2
therefore k=10,i=11
Precedence and Associativity https://www.geeksforgeeks.org/c-operator-precedence-associativity/
Ternary Operator https://www.geeksforgeeks.org/cc-ternary-operator-some-interesting-observations/