#define MAX(x,y) (x) > (y) ? (x) : (y)
main()
{
int i = 10, j = 5, k = 0;
k = MAX(i++, ++j);
printf("%d %d %d", i,j,k);
}

what will the values of i , j and k?
}




Answers were Sorted based on User's Feedback



Answer / guest

12 6 11

Is This Answer Correct ?    59 Yes 27 No

Answer / vidyullatha

In Linux:
O/P: 12 6 11

Explanation:
when k = MAX(i++,++j) is called the macro is replaced and
evaluated as, (i++) > (++j) i.e 11 > 6. As the result of
the statement is true, it executes the statement ? (X) i.e
(i++) on total the statement looks like this
(i++) > (++j) ? (i++)
i.e 11 > 6 ? (i++)
i.e k = i++;
Here as i is post increment first value of i is assigned to
k and then it is incremented.
Hence k = 11.
as i is incremented twice it value is 12
and j is incremented once hence 6
So final O/P is 12 6 11.

Hope this helps.

Is This Answer Correct ?    25 Yes 1 No

Answer / sumi

11 , 6, 10

Is This Answer Correct ?    49 Yes 28 No




Answer / sshireesha

12 6 11

Is This Answer Correct ?    25 Yes 9 No

Answer / vignesh1988i

i=12
j=6
k=11

Is This Answer Correct ?    21 Yes 5 No

Answer / vignesh1988i

i=12
j=6
k=11

Is This Answer Correct ?    19 Yes 10 No

Answer / amit kumar ram

i=11, j=6 , k=10.

bcoz i=10 and j=6 pass to function
then check and give k=x which is k=10
then increament i by 1 i.e i=11.

Is This Answer Correct ?    18 Yes 11 No

Answer / mukul

ans : 11 6 0

Is This Answer Correct ?    3 Yes 0 No

Answer / jason

The answer is undefined. It is undefined in C to use the
increment operator more than once in the same expression.

MAX(i++, ++j) expands to:

(i++) > (++j) ? (i++) : (++j)

Which guarantees that either i++ or ++j appears twice in the
expression.

http://blog.emptycrate.com/node/329

Is This Answer Correct ?    7 Yes 7 No

Answer / sunil v r

11,6,11

Is This Answer Correct ?    1 Yes 1 No

Post New Answer



More C Interview Questions

write a programme to enter some number and find which number is maximum and which number is minimum from enterd numbers.

3 Answers  


what is the different bitween abap and abap-hr?

0 Answers   TCS,


Write a progarm to find the length of string using switch case?

0 Answers   TCS,


what is the different between data structure and data type?

1 Answers   Ignou,


what is the difference between class and unio?

0 Answers   HCL, Wipro,






whitch value return void main?

11 Answers  


Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer

0 Answers   TCS,


Give the Output : * * * * * * * * * *

2 Answers  


write a program to display the numbers in the following 4 4 3 3 2 2 1 1 0 1 1 2 2 3 3 4 4

1 Answers  


code for bubble sort?

1 Answers  


pascal triangle program

2 Answers  


how does printf function work

1 Answers  






Categories