in Programming in C edited by
263 views
0 votes
0 votes

Read the following code fragment:

#include <stdio.h>
main()
{
int i=1,j;
int k= 1__ (j ___ i) ;
printf("%d%d%d\n", i,j,k);
}

What operators are needed in the blanks to print $1 \ 1 \ 2$?

  1. $*$ and $=$
  2. $*$ and $+$
  3. $+$ and $*$
  4. $+$ and $=$
in Programming in C edited by
by
263 views

2 Comments

edited by

Bikram sir, according to the answer this is the expression K=1 + j = i, here + is an binary operator which is having more precedence than assignment operator so j must take any garbage value not

Please check sir is it correct ?

BTW this program is not even working it is throwing lvalued error

check :https://ideone.com/eRRr9g

1
1
Because of the bracket the precedence of = inside () is higher than + operator in this case . I hope I cleared the doubt. Correct me if wrong.
0
0

1 Answer

0 votes
0 votes

Option D) is correct

$k=1+(j=i) $

Since $i=1$, and precedence of $()$ is greater than $+$

$k=1+1=2$

Answer:

Related questions