What will be the output of the program ?
#include <stdio.h>
int main()
{
int i=3, *j, k;
j = &i;
printf("%d\n", i**j*i+*j);
return 0;
}
Answer: A
Correct answer: 30
The expression i**j*i+*j looks alarming but tokenises unambiguously as i * (*j) * i + (*j): the lexer takes the longest valid token at each point, so ** becomes * followed by unary *.
With i = 3 and *j = 3:
\[ 3 \times 3 \times 3 + 3 = 27 + 3 = 30 \]
Multiplication binds tighter than addition, so no parentheses are needed to get this grouping.
Please log in or register to report this question.